當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。