当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Immutable.Seq函数代码示例

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


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

示例1: it

 it('concats two object sequences', () => {
   var a = Seq({a:1,b:2,c:3});
   var b = Seq({d:4,e:5,f:6});
   expect(a.size).toBe(3);
   expect(a.concat(b).size).toBe(6);
   expect(a.concat(b).toObject()).toEqual({a:1,b:2,c:3,d:4,e:5,f:6});
 })
开发者ID:AntanasBarauskas,项目名称:immutable-js,代码行数:7,代码来源:concat.ts

示例2: it

 it('some is true when predicate is true for any entry', () => {
   expect(Seq([]).some(() => true)).toBe(false);
   expect(Seq([1,2,3]).some(v => v > 0)).toBe(true);
   expect(Seq([1,2,3]).some(v => v < 3)).toBe(true);
   expect(Seq([1,2,3]).some(v => v > 1)).toBe(true);
   expect(Seq([1,2,3]).some(v => v < 0)).toBe(false);
 });
开发者ID:Harishs84,项目名称:immutable-js,代码行数:7,代码来源:ArraySeq.ts

示例3: it

 it('slices an unindexed sequence', () => {
   expect(Seq({a:1,b:2,c:3}).slice(1).toObject()).toEqual({b:2,c:3});
   expect(Seq({a:1,b:2,c:3}).slice(1, 2).toObject()).toEqual({b:2});
   expect(Seq({a:1,b:2,c:3}).slice(0, 2).toObject()).toEqual({a:1,b:2});
   expect(Seq({a:1,b:2,c:3}).slice(-1).toObject()).toEqual({c:3});
   expect(Seq({a:1,b:2,c:3}).slice(1, -1).toObject()).toEqual({b:2});
 })
开发者ID:Harishs84,项目名称:immutable-js,代码行数:7,代码来源:slice.ts

示例4: expect

 check.it('is not dependent on order', [genHeterogeneousishArray], vals => {
   expect(
     is(
       Seq(shuffle(vals.slice())).max(),
       Seq(vals).max()
     )
   ).toEqual(true);
 });
开发者ID:AntanasBarauskas,项目名称:immutable-js,代码行数:8,代码来源:minmax.ts

示例5: it

  it('cannot be mutated after calling toObject', () => {
    var seq = Seq({ a: 1, b: 2, c: 3 });

    var obj = seq.toObject();
    obj['c'] = 10;
    var seq2 = Seq(obj);

    expect(seq.get('c')).toEqual(3);
    expect(seq2.get('c')).toEqual(10);
  });
开发者ID:AntanasBarauskas,项目名称:immutable-js,代码行数:10,代码来源:ObjectSeq.ts

示例6: it

 it('compares sequences', () => {
   var arraySeq = Seq.of(1,2,3);
   var arraySeq2 = Seq([1,2,3]);
   expectIs(arraySeq, arraySeq);
   expectIs(arraySeq, Seq.of(1,2,3));
   expectIs(arraySeq2, arraySeq2);
   expectIs(arraySeq2, Seq([1,2,3]));
   expectIsNot(arraySeq, [1,2,3]);
   expectIsNot(arraySeq2, [1,2,3]);
   expectIs(arraySeq, arraySeq2);
   expectIs(arraySeq, arraySeq.map(x => x));
   expectIs(arraySeq2, arraySeq2.map(x => x));
 });
开发者ID:AntanasBarauskas,项目名称:immutable-js,代码行数:13,代码来源:Equality.ts

示例7: it

  it('groups keyed sequence', () => {
    var grouped = Seq({a:1,b:2,c:3,d:4}).groupBy(x => x % 2);
    expect(grouped.toJS()).toEqual({1:{a:1,c:3}, 0:{b:2,d:4}});

    // Each group should be a keyed sequence, not an indexed sequence
    expect(grouped.get(1).toArray()).toEqual([1, 3]);
  })
开发者ID:Harishs84,项目名称:immutable-js,代码行数:7,代码来源:groupBy.ts

示例8: it

 it('is stable', () => {
   var i = new SimpleIterable();
   var s = Seq(i);
   expect(s.take(5).toArray()).toEqual([ 0,1,2,3,4 ]);
   expect(s.take(5).toArray()).toEqual([ 0,1,2,3,4 ]);
   expect(s.take(5).toArray()).toEqual([ 0,1,2,3,4 ]);
 })
开发者ID:Azatey,项目名称:immutable-js,代码行数:7,代码来源:IterableSeq.ts


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