本文整理汇总了TypeScript中Immutable.Range函数的典型用法代码示例。如果您正苦于以下问题:TypeScript Range函数的具体用法?TypeScript Range怎么用?TypeScript Range使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Range函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it("should get a different random bag each time", () => {
const random = new BagRandomizer(0);
const bag = Set(Range(0, polyominoes.size).map(() =>
random.getNextShape()
));
const nextBag = Set(Range(0, polyominoes.size).map(() =>
random.getNextShape()
));
expect(nextBag.toString()).not.to.equal(bag.toString());
});
示例2: it
it('zips with infinite lists', () => {
expect(
Range().zip(Seq.of('A','B','C')).toArray()
).toEqual(
[[0,'A'],[1,'B'],[2,'C']]
);
});
示例3: it
it("should return sum of list", () => {
const list = Range(1, Infinity).take(100).toList();
const expected = 5050;
const actual = sum_list(list);
expect(5050).toBe(sum_list(list));
});
示例4: _modifySithIDs
function _modifySithIDs(state: AppState, n: number, f): AppState {
let {sithIDs} = state;
Range(0, n).forEach(() => {
sithIDs = f(sithIDs);
});
return cleanCache(discoverSiths(assoc(state, {sithIDs})));
}
示例5: Range
(valuesLen, args) => {
var a = Range(0, valuesLen).toArray();
var v = List(a);
var slicedV = v.slice.apply(v, args);
var slicedA = a.slice.apply(a, args);
expect(slicedV.toArray()).toEqual(slicedA);
})
示例6: Range
check.it('has and get', {maxSize: 5000}, [gen.posInt], len => {
var map = Range(0, len).toKeyedSeq().mapKeys(x => ''+x).toMap();
for (var ii = 0; ii < len; ii++) {
expect(map.get(''+ii)).toBe(ii);
expect(map.has(''+ii)).toBe(true);
}
});
示例7: it
it('takes and skips values', () => {
var v = Range(0, 100, 3)
var r = v.skip(2).take(2);
expect(r.toArray()).toEqual([6, 9]);
});
示例8: it
it('has the same behavior as array splice in known edge cases', () => {
// arbitary numbers that sum to 31
var a = Range(0, 49).toArray();
var v = List(a);
a.splice(-18, 0, 0);
expect(v.splice(-18, 0, 0).toList().toArray()).toEqual(a);
})
示例9: it
it('separates with a value', () => {
var range = Range(10, 15);
var interposed = range.interpose(0);
expect(interposed.toArray()).toEqual(
[ 10, 0, 11, 0, 12, 0, 13, 0, 14 ]
);
})
示例10: it
it('maintains keys', () => {
var isEven = x => x % 2 === 0;
var seq = Range(0, 100);
// This is what we expect for IndexedSequences
var operated = seq.filter(isEven).skip(10).take(5);
expect(operated.entrySeq().toArray()).toEqual([
[0, 20],
[1, 22],
[2, 24],
[3, 26],
[4, 28],
]);
// Where Keyed Sequences maintain keys.
var keyed = seq.toKeyedSeq();
var keyedOperated = keyed.filter(isEven).skip(10).take(5);
expect(keyedOperated.entrySeq().toArray()).toEqual([
[20, 20],
[22, 22],
[24, 24],
[26, 26],
[28, 28],
]);
});
示例11: it
it('can map items known to hash collide', () => {
// make a big map, so it hashmaps
var m: Map<any, any> = Range(0, 32).toMap();
var m = m.set('AAA', 'letters').set(64545, 'numbers');
expect(m.size).toBe(34);
expect(m.get('AAA')).toEqual('letters');
expect(m.get(64545)).toEqual('numbers');
});
示例12: Range
check.it('deletes from transient', {maxSize: 5000}, [gen.posInt], len => {
var map = Range(0, len).toMap().asMutable();
for (var ii = 0; ii < len; ii++) {
expect(map.size).toBe(len - ii);
map.remove(ii);
}
expect(map.size).toBe(0);
expect(map.toObject()).toEqual({});
});
示例13: Map
check.it('sets', {maxSize: 5000}, [gen.posInt], len => {
var map = Map();
for (var ii = 0; ii < len; ii++) {
expect(map.size).toBe(ii);
map = map.set(''+ii, ii);
}
expect(map.size).toBe(len);
expect(is(map.toSet(), Range(0, len).toSet())).toBe(true);
});
示例14: it
it('first maps, then shallow flattens', () => {
var numbers = Range(97, 100);
var letters = numbers.flatMap(v => fromJS([
String.fromCharCode(v),
String.fromCharCode(v).toUpperCase(),
]));
expect(letters.toJS()).toEqual(
['a','A','b','B','c','C']
)
});
示例15: toPoints
toPoints(){
const left = this.minColumnNo;
const right = this.maxColumnNo;
const top = this.minRowNo;
const bottom = this.maxRowNo;
let points = List<CellPoint>();
Range(left, right + 1).forEach((columnNo) => {
Range(top, bottom + 1).forEach((rowNo) => {
points = points.push(CellPoint.create(columnNo, rowNo));
});
});
return points;
}