• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript lodash.range函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: getKeySet

export function getKeySet(customKeys: Array<string>) {
    let lowerCharacters: Array<string> = [];
    let upperCharacters: Array<string> = [];

    if (!customKeys.length) {
        lowerCharacters = _.range('a'.charCodeAt(0), 'z'.charCodeAt(0) + 1 /* for inclusive*/)
            .map(c => String.fromCharCode(c));
        upperCharacters = _.range('A'.charCodeAt(0), 'Z'.charCodeAt(0) + 1 /* for inclusive*/)
            .map(c => String.fromCharCode(c));
    } else {
        for (let key of customKeys) {
            lowerCharacters.push(key.toLowerCase());
            upperCharacters.push(key.toUpperCase());
        }
    }

    const keys: Array<string> = [];

    // A little ugly.
    // I used itertools.permutation in python.
    // Couldn't find a good one in npm.  Don't worry this takes < 1ms once.
    // TODO: try a zip? and or make a func
    for (let c1 of lowerCharacters) {
        for (let c2 of lowerCharacters) {
            keys.push(c1 + c2);
        }
    }
    for (let c1 of upperCharacters) {
        for (let c2 of lowerCharacters) {
            keys.push(c1 + c2);
        }
    }
    for (let c1 of lowerCharacters) {
        for (let c2 of upperCharacters) {
            keys.push(c1 + c2);
        }
    }

    // TODO: use TS's ReadonlyArray?
    return keys;
}
开发者ID:DavidLGoldberg,项目名称:jumpy,代码行数:41,代码来源:keys.ts


示例17: main

async function main() {
  const writer = fs.createWriteStream(path.join(__dirname, 'address.json'))
  const api_url = 'http://maps.ottawa.ca/arcgis/rest/services/Property_Parcels/MapServer/0/query'
  let count = 0
  let first = false
  const max = 250
  const features: Array<GeoJSON.Feature<GeoJSON.Point>> = []

  // Write Feature Collection Header
  writer.write(`{
  "type": "FeatureCollection",
  "features": [
`)

  while (true) {
    const params = {
      objectIds: range(count, count + max).join(','),
      geometryType: 'esriGeometryEnvelope',
      spatialRel: 'esriSpatialRelIntersects',
      outFields: '*',
      returnGeometry: 'true',
      returnTrueCurves: 'false',
      returnIdsOnly: 'false',
      returnCountOnly: 'false',
      returnDistinctValues: 'false',
      outSR: 4326,
      f: 'pjson',
    }
    const url = `${ api_url }?${ encodeData(params)}`
    const r:InterfaceESRIResults = await rp.get(url)
      .then(data => JSON.parse(data))
    r.features.map(feature => {
      const attributes = {
        source: 'City of Ottawa'
      }
      const point = turf.point([feature.geometry.x, feature.geometry.y], feature.attributes)
      if (!first) {
        writer.write(`    ${ JSON.stringify(point)}`)
        first = true
      } else writer.write(`,\n    ${ JSON.stringify(point)}`)
    })

    // Stop or Start over
    if (!r.features.length) break
    console.log(count)
    count += max

    // if (count > 1000) break
  }
  writer.write(`
  ]
}`)
}
开发者ID:osmottawa,项目名称:imports,代码行数:53,代码来源:get-data-address.ts


示例18: expect

 .then((responses: Execution.IExecutionResponses) => {
     expect(responses).toEqual({
         executionResponse: getExecutionResponse(1),
         executionResult: {
             headerItems: [
                 [
                     [
                         ...range(DEFAULT_TEST_LIMIT + 1)
                             .map((i: number) => createMeasureHeaderItem(`m${i + 1}`, i + 1))
                     ]
                 ]
             ],
             data: range(1, DEFAULT_TEST_LIMIT + 2),
             paging: {
                 count: [DEFAULT_TEST_LIMIT + 1],
                 offset: [0],
                 total: [DEFAULT_TEST_LIMIT + 1]
             }
         }
     });
 });
开发者ID:gooddata,项目名称:gooddata-js,代码行数:21,代码来源:execute-afm.test.ts


示例19: constructor

 constructor (width: number = 8, height: number = 8, types: Orb[] = _.range(7), needsAttic: boolean = true) {
     this.width = width;
     this.height = height;
     this.types = types;
     this.generateOrbs();
     if (this.hasMatch() || this.needsShuffle()) {
         this.shuffle();
     };
     if (needsAttic) {
         this.attic = new Board(this.width, this.height, this.types, false);
     };
 }
开发者ID:rbcasperson,项目名称:match-three-js,代码行数:12,代码来源:board.ts


示例20: before

 before((done: MochaDone) => {
   async.each(
     _.range(3),
     (i: number, callback: Function) => {
       let item = new testModel({ name: 'item' + i });
       item.save(() => {
         idList.push(item._id.toString());
         callback();
       });
     },
     done);
 });
开发者ID:apelade,项目名称:hapi-mongoose,代码行数:12,代码来源:get.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript lodash.reduce函数代码示例发布时间:2022-05-25
下一篇:
TypeScript lodash.random函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap