本文整理汇总了TypeScript中Immutable.Seq.of方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Seq.of方法的具体用法?TypeScript Seq.of怎么用?TypeScript Seq.of使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Immutable.Seq
的用法示例。
在下文中一共展示了Seq.of方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('slices a sequence', () => {
expect(Seq.of(1,2,3,4,5,6).slice(2).toArray()).toEqual([3,4,5,6]);
expect(Seq.of(1,2,3,4,5,6).slice(2, 4).toArray()).toEqual([3,4]);
expect(Seq.of(1,2,3,4,5,6).slice(-3, -1).toArray()).toEqual([4,5]);
expect(Seq.of(1,2,3,4,5,6).slice(-1).toArray()).toEqual([6]);
expect(Seq.of(1,2,3,4,5,6).slice(0, -1).toArray()).toEqual([1,2,3,4,5]);
})
示例2: it
it('zips lists into a list of tuples', () => {
expect(
Seq.of(1,2,3).zip(Seq.of(4,5,6)).toArray()
).toEqual(
[[1,4],[2,5],[3,6]]
);
});
示例3: it
it('concats two sequences', () => {
var a = Seq.of(1,2,3);
var b = Seq.of(4,5,6);
expect(a.concat(b)).is(Seq.of(1,2,3,4,5,6))
expect(a.concat(b).size).toBe(6);
expect(a.concat(b).toArray()).toEqual([1,2,3,4,5,6]);
})
示例4: it
it('differentiates decimals', () => {
expect(
Seq.of(1.5).hashCode()
).not.toBe(
Seq.of(1.6).hashCode()
);
});
示例5: it
it('lazily evaluates Seq with unknown length', () => {
var seq = Seq.of(1,2,3,4,5,6).filter(x => x % 2 === 0);
expect(seq.size).toBe(undefined);
expect(seq.isEmpty()).toBe(false);
expect(seq.size).toBe(undefined);
var seq = Seq.of(1,2,3,4,5,6).filter(x => x > 10);
expect(seq.size).toBe(undefined);
expect(seq.isEmpty()).toBe(true);
expect(seq.size).toBe(undefined);
})
示例6: it
it('groups indexed sequences, maintaining indicies when keyed sequences', () => {
expect(
Seq.of(1,2,3,4,5,6).groupBy(x => x % 2).toJS()
).toEqual(
{1:[1,3,5], 0:[2,4,6]}
);
expect(
Seq.of(1,2,3,4,5,6).toKeyedSeq().groupBy(x => x % 2).toJS()
).toEqual(
{1:{0:1, 2:3, 4:5}, 0:{1:2, 3:4, 5:6}}
);
})