本文整理匯總了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}}
);
})