當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Iterable.slice方法代碼示例

本文整理匯總了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)
}
開發者ID:justjake,項目名稱:fett,代碼行數:7,代碼來源:orderReducer.ts

示例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}`))
      })

    })
開發者ID:justjake,項目名稱:fett,代碼行數:31,代碼來源:orderReducer.ts

示例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')
 })
開發者ID:justjake,項目名稱:fett,代碼行數:7,代碼來源:orderReducer.ts


注:本文中的Immutable.Iterable.slice方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。