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


TypeScript lodash.range函数代码示例

本文整理汇总了TypeScript中lodash.range函数的典型用法代码示例。如果您正苦于以下问题:TypeScript range函数的具体用法?TypeScript range怎么用?TypeScript range使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了range函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: function

 const hakuVastaus = function(vastaus) {
     $scope.perusteet = vastaus;
     $scope.nykyinenSivu = $scope.perusteet.sivu + 1;
     $scope.hakuparametrit.sivukoko = $scope.perusteet.sivukoko;
     $scope.sivuja = $scope.perusteet.sivuja;
     $scope.kokonaismaara = $scope.perusteet.kokonaismäärä;
     $scope.sivut = _.range(0, $scope.perusteet.sivuja);
     pat = new RegExp("(" + $scope.hakuparametrit.nimi + ")", "i");
 };
开发者ID:Opetushallitus,项目名称:eperusteet,代码行数:9,代码来源:haku.ts

示例2: toString

 public toString() : string {
     let res = '' // 'Goal ' + this.goalId + '\n\n'
     this.goalHyp.forEach(h => {
         res += h + '\n'
     })
     _.range(80).forEach(() => { res += '-' })
     res += '\n' + this.goalCcl
     return res
 }
开发者ID:Ptival,项目名称:PeaCoq,代码行数:9,代码来源:goal.ts

示例3: withIndex

function withIndex(callCluster: sinon.SinonStub, opts: any = {}) {
  const defaultIndex = {
    '.kibana_1': {
      aliases: { '.kibana': {} },
      mappings: {
        doc: {
          dynamic: 'strict',
          properties: {
            migrationVersion: { dynamic: 'true', type: 'object' },
          },
        },
      },
    },
  };
  const defaultAlias = {
    '.kibana_1': {},
  };
  const { numOutOfDate = 0 } = opts;
  const { alias = defaultAlias } = opts;
  const { index = defaultIndex } = opts;
  const { docs = [] } = opts;
  const searchResult = (i: number) =>
    Promise.resolve({
      _scroll_id: i,
      _shards: {
        successful: 1,
        total: 1,
      },
      hits: {
        hits: docs[i] || [],
      },
    });
  callCluster.withArgs('indices.get').returns(Promise.resolve(index));
  callCluster.withArgs('indices.getAlias').returns(Promise.resolve(alias));
  callCluster
    .withArgs('reindex')
    .returns(Promise.resolve({ task: 'zeid', _shards: { successful: 1, total: 1 } }));
  callCluster.withArgs('tasks.get').returns(Promise.resolve({ completed: true }));
  callCluster.withArgs('search').returns(searchResult(0));

  _.range(1, docs.length).forEach(i => {
    callCluster
      .withArgs('scroll')
      .onCall(i - 1)
      .returns(searchResult(i));
  });

  callCluster
    .withArgs('scroll')
    .onCall(docs.length - 1)
    .returns(searchResult(docs.length));

  callCluster.withArgs('bulk').returns(Promise.resolve({ items: [] }));
  callCluster
    .withArgs('count')
    .returns(Promise.resolve({ count: numOutOfDate, _shards: { successful: 1, total: 1 } }));
}
开发者ID:gingerwizard,项目名称:kibana,代码行数:57,代码来源:index_migrator.test.ts

示例4: test

  test('it should assign colors deterministically', () => {
    const lessons: Lesson[] = [];
    range(NUM_DIFFERENT_COLORS).forEach((i) => {
      // Add 2 lessons for this ith venue
      const newLesson = { ...bareLesson, venue: `LT${i}` };
      lessons.push(newLesson);
      lessons.push(newLesson);
    });

    const coloredLessons = colorLessonsByKey(lessons, 'venue');

    range(NUM_DIFFERENT_COLORS * 2).forEach((i) => {
      const coloredLesson = coloredLessons[i];
      const index = Math.floor(i / 2);
      expect(coloredLesson).toMatchObject(bareLesson); // Ensure that existing lesson info wasn't modified
      expect(coloredLesson).toHaveProperty('venue', `LT${index}`);
      expect(coloredLesson).toHaveProperty('colorIndex', index % NUM_DIFFERENT_COLORS);
    });
  });
开发者ID:nusmodifications,项目名称:nusmods,代码行数:19,代码来源:colors.test.ts

示例5: getTrainingSet

async function getTrainingSet() {
    const peopleArray = await of(...range(5, 10), 2)
        .pipe(map(x => `https://swapi.co/api/people/?format=json&page=${x}`))
        .pipe(flatMap(x => Axios.get(x).catch(console.error)))
        .pipe(map((x: AxiosResponse) => x.data))
        .pipe(reduce((acc: any[], x: any) => [x, ...acc], []))
        .toPromise();

    console.log(JSON.stringify(peopleArray, null, 2));
}
开发者ID:vba,项目名称:DecisionTrees,代码行数:10,代码来源:starwars.ts

示例6: it

  it('should merge snippets if necessary', () => {
    const lines = keyBy(
      range(4, 23)
        .concat(range(38, 43))
        .map(line => mockSourceLine({ line })),
      'line'
    );
    const snippets = [
      [lines[4], lines[5], lines[6], lines[7], lines[8]],
      [lines[38], lines[39], lines[40], lines[41], lines[42]],
      [lines[17], lines[18], lines[19], lines[20], lines[21]]
    ];

    const result = expandSnippet({ direction: 'down', lines, snippetIndex: 0, snippets });

    expect(result).toHaveLength(2);
    expect(result[0].map(l => l.line)).toEqual(range(4, 22));
    expect(result[1].map(l => l.line)).toEqual(range(38, 43));
  });
开发者ID:SonarSource,项目名称:sonarqube,代码行数:19,代码来源:utils-test.ts

示例7: appData

function appData(state: any = { list: [] }, action) {
    switch(action.type) {
        case GET_LIST:
            return {
                list: _.range(20)
            };
    }

    return state;
}
开发者ID:kenjiru,项目名称:loading-state-demo,代码行数:10,代码来源:reducers.ts

示例8: uploadMulti

  uploadMulti() {
    let files = this.selectedFiles
    if (_.isEmpty(files)) return;

    let filesIndex = _.range(files.length)
    _.each(filesIndex, (idx) => {
      this.currentUpload = new Upload(files[idx]);
      this.upSvc.pushUpload(this.currentUpload)}
    )
  }
开发者ID:meataur,项目名称:angular-firestarter,代码行数:10,代码来源:upload-form.component.ts

示例9: weekRangeToArray

export function weekRangeToArray(weekRange: WeekRange) {
    return _.range(weekRange.startWeek, weekRange.endWeek + 1).filter(w => {
        return weekRange.oddEven === 0
             ? true
             : weekRange.oddEven === 1
             ? w % 2 === 1
             : weekRange.oddEven === 2
             ? w % 2 === 0
             : false;
    });
}
开发者ID:Gitjerryzhong,项目名称:bell-tm-static,代码行数:11,代码来源:week-range.ts

示例10: makeList

function makeList(values: Array<string>, power: number, start = 0) {
    return _.map(
        _.range(start, values.length + start),
        function(i) {
            return {
                label: values[i - start],
                value: Math.pow(power, i)
            };
        }
    );
}
开发者ID:mactanxin,项目名称:gui,代码行数:11,代码来源:Units.ts

示例11:

 _.each(_.range(height), col => {
     let blankCount = 0;
     _.each(_.range(1, height - row), adder => {
         if (orbs[row + adder][col] === '\u241a') {
             blankCount += 1;
         };
     });
     if (blankCount > 0) {
         blanksBelow[`${row}, ${col}`] = blankCount;
     };
 });
开发者ID:PlaytestersKitchen,项目名称:match-three-js,代码行数:11,代码来源:evaluate.ts

示例12: testModel

 () => {
   async.each(
     _.range(3),
     (i: number, callback: Function) => {
       let item = new testModel({ name: 'item' + (5 - i), index: (5 - i) });
       item.save(() => {
         callback();
       });
     },
     done);
 });
开发者ID:apelade,项目名称:hapi-mongoose,代码行数:11,代码来源:sort.ts

示例13: sameBodyAndType

function sameBodyAndType(hyp1 : HTMLElement, hyp2 : HTMLElement) : boolean {
  const children1 = $(hyp1).children().slice(1)
  const children2 = $(hyp2).children().slice(1)
  if (children1.length !== children2.length) { return false }
  for (const i in _.range(children1.length)) {
    if ($(children1[i]).html() !== $(children2[i]).html()) {
      return false
    }
  }
  return true
}
开发者ID:Ptival,项目名称:PeaCoq,代码行数:11,代码来源:goal.ts

示例14: it

    it('should setTimeslot', function () {
        const schedule = new Schedule();
        assert.throw(() => { schedule.setTimeslots([false]); }, 'timeslot should be 24 in length');

        const timeslots: boolean[] = Array<boolean>(24);
        _.forEach(_.range(24), (i) => timeslots[i] = false);

        timeslots[0] = true;
        schedule.setTimeslots(timeslots);
        assert.equal(schedule.toJSON(), 1, 'should allow setting timeslot in array of boolean');
    });
开发者ID:kaga,项目名称:Home-Sensor,代码行数:11,代码来源:schedule.unit.ts

示例15: cart2sph

/**
 * Convert cartesian coordinates to spherical coordinates
 *
 * @param x - array of x coordinates
 * @param y - array of y coordinates
 * @param z - arrya of z coordinates
 */
function cart2sph(x: number[], y: number[], z: number[]) {
    var range = _.range(x.length)
    var r = range.map(i => Math.sqrt(x[i] * x[i] + y[i] * y[i] + z[i] * z[i]))
    var elev = range.map(i => Math.atan2(z[i], Math.sqrt(x[i] * x[i] + y[i] * y[i])))
    var az = range.map(i => Math.atan2(y[i], x[i]))
    return {
        r: r,
        elev: elev,
        az: az
    }
}
开发者ID:timofeevda,项目名称:seismic-beachballs,代码行数:18,代码来源:bbutils.ts


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