本文整理汇总了TypeScript中Immutable.Iterable.slice方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Iterable.slice方法的具体用法?TypeScript Iterable.slice怎么用?TypeScript Iterable.slice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Immutable.Iterable
的用法示例。
在下文中一共展示了Iterable.slice方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: multiShard
function multiShard(): T {
const shards = List.of(
mkShard(reqs.slice(3, 5)),
mkShard(reqs.slice(5, 10))
)
return mkOrder(reqs.slice(0, 3), shards)
}
示例2: context
context('some locks', function() {
const locked = mkShard(reqs.slice(2, 10), true)
const oldState = mkOrder(
reqs.slice(0, 2),
List.of(
locked,
mkShard(reqs.slice(10, 20)),
mkShard(reqs.slice(20, 30))
)
)
const newState = reducer(oldState, orderActions.balanceShards({maxSize: 4, userId: 'bepis'}))
const unlocked = newState.shards.filter(s => !s.locked)
sameSize(oldState, newState)
it('preserves the locked shard', function() {
const newLocked = newState.shards.find(s => s.locked)
assert.strictEqual(newLocked, locked, 'locked shard unchanged')
assert.strictEqual(newLocked.requests.size, 8, 'still has 8 reqs')
})
it('has a bunch of unlocked shards', function() {
assert.ok(unlocked.size > 2, 'yerp')
})
it('unlocked shards all have size < max size', function() {
unlocked.forEach(
(s, i) => assert.ok(s.requests.size <= 4, `bigger shard ${i}`))
})
})
示例3: it
it('removes the correct request from unshardedRequests', function() {
const oldState = mkOrder(reqs.slice(0, 5).toList())
const newState = reducer(oldState, orderActions.cancelRequest({userId: '3'}))
assert.strictEqual(newState.unshardedRequests.size, 4, 'did remove one')
newState.unshardedRequests.forEach(r => assert(r.userId !== '3', 'remaining id is not 3'))
assert.strictEqual(allReqs(newState).size, allReqs(oldState).size - 1, 'one less req')
})