• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript Immutable.Iterable类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中Immutable.Iterable的典型用法代码示例。如果您正苦于以下问题:TypeScript Iterable类的具体用法?TypeScript Iterable怎么用?TypeScript Iterable使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Iterable类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: it

  it('returns an ordered map from an ordered collection', () => {
    var seq = Seq.of('Z','Y','X','Z','Y','X');
    expect(Iterable.isOrdered(seq)).toBe(true);
    var seqGroups = seq.groupBy(x => x);
    expect(Iterable.isOrdered(seqGroups)).toBe(true);

    var map = Map({ x: 1, y: 2 });
    expect(Iterable.isOrdered(map)).toBe(false);
    var mapGroups = map.groupBy(x => x);
    expect(Iterable.isOrdered(mapGroups)).toBe(false);
  })
开发者ID:Harishs84,项目名称:immutable-js,代码行数:11,代码来源:groupBy.ts


示例2:

const stateTransformer = (state) => {
    const newState = {};
    for (let i of Object.keys(state)) {
        newState[i] = Iterable.isIterable(state[i]) ? state[i].toJS() : state[i];
    }
    return newState;
};
开发者ID:asiam9,项目名称:angularattack2016-dices-game,代码行数:7,代码来源:boot.ts


示例3: stateTransformer

function stateTransformer(state) {
  const newState = {};
  for (const i of Object.keys(state)) {
    newState[i] = Iterable.isIterable(state[i]) ? state[i].toJS() : state[i];
  }
  return newState;
}
开发者ID:rtbm,项目名称:ng2-quottr,代码行数:7,代码来源:middlewares.ts


示例4: mkShard

function mkShard(reqs: Iterable<number, Request> = List<Request>(), locked = false): Shard {
  return {
    leaderId: undefined,
    label: undefined,
    locked: locked,
    ordered: false,
    delivered: false,
    requests: reqs.toList(),
  }
}
开发者ID:justjake,项目名称:fett,代码行数:10,代码来源:orderReducer.ts


示例5:

 stateTransformer: (state) => {
     let newState = {};
     for (let i of Object.keys(state)) {
         if (Iterable.isIterable(state[i])) {
             newState[i] = state[i].toJS();
         } else {
             newState[i] = state[i];
         }
     };
     return newState;
 }
开发者ID:AbdellaToronto,项目名称:angular2-redux-starter,代码行数:11,代码来源:configure-logger.ts


示例6: 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


示例7: 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


示例8: it

    it('does not add a second request for the same user', function() {
      const oldState = mkOrder(reqs.slice(0, 1))
      const req = reqs.get(0)
      const newState = reducer(oldState, orderActions.makeRequest(
        {userId: '0', text: 'bla', createdAt: new Date()}))

      assert.strictEqual(oldState.unshardedRequests.size, 1, 'one requests before')
      assert.strictEqual(newState.unshardedRequests.size, 1, 'now 1 req')
    });
开发者ID:justjake,项目名称:fett,代码行数:9,代码来源:orderReducer.ts



注:本文中的Immutable.Iterable类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript Immutable.List类代码示例发布时间:2022-05-25
下一篇:
TypeScript Immutable.is函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap