當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。