当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Immutable.Range函数代码示例

本文整理汇总了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());
 });
开发者ID:wjordan,项目名称:tetrominode,代码行数:10,代码来源:RandomizerTest.ts

示例2: it

 it('zips with infinite lists', () => {
   expect(
     Range().zip(Seq.of('A','B','C')).toArray()
   ).toEqual(
     [[0,'A'],[1,'B'],[2,'C']]
   );
 });
开发者ID:AntanasBarauskas,项目名称:immutable-js,代码行数:7,代码来源:zip.ts

示例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));
  });
开发者ID:ababup1192,项目名称:typescript-template,代码行数:7,代码来源:collections-test.ts

示例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})));
}
开发者ID:CmdrDats,项目名称:flux-challenge,代码行数:7,代码来源:model.ts

示例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);
 })
开发者ID:Harishs84,项目名称:immutable-js,代码行数:7,代码来源:slice.ts

示例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);
   }
 });
开发者ID:AntanasBarauskas,项目名称:immutable-js,代码行数:7,代码来源:Map.ts

示例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]);
  });
开发者ID:Harishs84,项目名称:immutable-js,代码行数:7,代码来源:Range.ts

示例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);
 })
开发者ID:AntanasBarauskas,项目名称:immutable-js,代码行数:7,代码来源:splice.ts

示例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 ]
   );
 })
开发者ID:AntanasBarauskas,项目名称:immutable-js,代码行数:7,代码来源:interpose.ts

示例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],
    ]);
  });
开发者ID:AntanasBarauskas,项目名称:immutable-js,代码行数:25,代码来源:KeyedSeq.ts

示例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');
 });
开发者ID:threehams,项目名称:immutable-js,代码行数:8,代码来源:Map.ts

示例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({});
 });
开发者ID:threehams,项目名称:immutable-js,代码行数:9,代码来源:Map.ts

示例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);
 });
开发者ID:threehams,项目名称:immutable-js,代码行数:9,代码来源:Map.ts

示例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']
   )
 });
开发者ID:AntanasBarauskas,项目名称:immutable-js,代码行数:10,代码来源:flatten.ts

示例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;
 }
开发者ID:BloodyEnterprise,项目名称:react-gridview,代码行数:13,代码来源:cell-range.ts


注:本文中的Immutable.Range函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。