本文整理汇总了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});
})
示例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);
});
示例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});
})
示例4: expect
check.it('is not dependent on order', [genHeterogeneousishArray], vals => {
expect(
is(
Seq(shuffle(vals.slice())).max(),
Seq(vals).max()
)
).toEqual(true);
});
示例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);
});
示例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));
});
示例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]);
})
示例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 ]);
})