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

TypeScript lodash.times函数代码示例

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

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



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

示例1: timelineSeries

 timelineSeries(count = 8) {
   const offsets = shuffle(times(count, (index) => index));
   const labels = [['Confort', 'icon-bed'],
   ['Eco', 'icon-leaf'],
   ['Night', 'icon-moon'],
   ['Game', 'icon-gamepad'],
   ['Recreation', 'icon-keyboard'],
   ['Visit', 'icon-stethoscope'],
   ['Work', 'icon-briefcase'],
   ['Shopping', 'icon-shopping-bag']];
   return times(count, (index) => {
     const offset = offsets.pop();
     const title = labels.pop();
     const date = new Date().getTime();
     const seeek = random(-72, 72);
     const begin = date + (seeek * 10000);
     return {
       data: this.getDataSeries(begin, offset),
       lineWidth: 10,
       name: {
         title: title[0],
         icon: title[1]
       }
     };
   });
 }
开发者ID:syafiqrokman,项目名称:angular5-iot-dashboard,代码行数:26,代码来源:reminder-timeline.component.ts


示例2: group

  group(end => {
    // construct a set of mocked responses that each
    // returns an author with a different id (but the
    // same name) so we can populate the cache.
    const mockedResponses: MockedResponse[] = [];
    times(count, index => {
      const result = cloneDeep(originalResult);
      result.data.author.id = index;

      const variables = cloneDeep(originalVariables);
      variables.id = index;

      mockedResponses.push({
        request: { query, variables },
        result,
      });
    });

    const client = new ApolloClient({
      networkInterface: mockNetworkInterface(...mockedResponses),
      addTypename: false,
      dataIdFromObject,
    });

    // insert a bunch of stuff into the cache
    const promises = times(count, index => {
      return client
        .query({
          query,
          variables: { id: index },
        })
        .then(result => {
          return Promise.resolve({});
        });
    });

    const myBenchmark = benchmark;
    const myAfterEach = afterEach;
    Promise.all(promises).then(() => {
      myBenchmark(
        {
          name: `read single item from cache with ${count} items in cache`,
          count,
        },
        done => {
          const randomIndex = Math.floor(Math.random() * count);
          client
            .query({
              query,
              variables: { id: randomIndex },
            })
            .then(result => {
              done();
            });
        },
      );

      end();
    });
  });
开发者ID:hammadj,项目名称:apollo-client,代码行数:60,代码来源:index.ts


示例3: it

		it('should combine websocket frame chunks', async () => {
			const port = newFirebaseServer();
			const client = newFirebaseClient(port);
			await client.set({
				foo: _.times(2000, String),
			});
			assert.deepEqual((await server.getValue()), {
				foo: _.times(2000, String),
			});
		});
开发者ID:urish,项目名称:firebase-server,代码行数:10,代码来源:server.spec.ts


示例4: randomIndex

export function randomIndex(len: number): number[] {
  let indexArr: number[] = [];
  let retArr: number[] = [];
  let r: number;
  _.times(len, (i) => {
    indexArr.push(i);
  });
  _.times(len, (i) => {
    r = _.random(len - 1 - i);
    retArr.push(indexArr[r]);
    _.pullAt(indexArr, r);
  });
  return retArr;
}
开发者ID:miluu,项目名称:createjs-tetris,代码行数:14,代码来源:index.ts


示例5: scheduler

export function scheduler({ originTime,
  intervalSeconds,
  lowerBound,
  upperBound }: SchedulerProps): Moment[] {
  if (!intervalSeconds) { // 0, NaN and friends
    return [originTime];
  }
  upperBound = upperBound || nextYear();
  // # How many items must we skip to get to the first occurence?
  let skip_intervals =
    Math.ceil((lowerBound.unix() - originTime.unix()) / intervalSeconds);
  // # At what time does the first event occur?
  let first_item = originTime
    .clone()
    .add((skip_intervals * intervalSeconds), "seconds");
  let list = [first_item];

  times(60, () => {
    let x = last(list);
    if (x) {
      let item = x.clone().add(intervalSeconds, "seconds");
      if (item.isBefore(upperBound)) {
        list.push(item);
      }
    }
  });
  return list;
}
开发者ID:MrChristofferson,项目名称:Farmbot-Web-API,代码行数:28,代码来源:scheduler.ts


示例6: sampleMany

export function sampleMany(n: number = 1, attributes: any): Array<Model> {
	return _.times(n, n => {
		let compiledAttributes: any = sampleRaw(attributes, n);

		return new Model(compiledAttributes);
	});
}
开发者ID:feliperohdee,项目名称:one-request-transport,代码行数:7,代码来源:model.ts


示例7: getClientInstance

      done => {
        const promises: Promise<void>[] = [];
        const client = getClientInstance();

        times(count, () => {
          promises.push(
            new Promise<void>((resolve, reject) => {
              client
                .watchQuery({
                  query: simpleQuery,
                  fetchPolicy: 'cache-only',
                })
                .subscribe({
                  next(res: ApolloQueryResult<Object>) {
                    if (Object.keys(res.data).length > 0) {
                      resolve();
                    }
                  },
                });
            }),
          );
        });

        client.query({ query: simpleQuery });
        Promise.all(promises).then(() => {
          done();
        });
      },
开发者ID:hammadj,项目名称:apollo-client,代码行数:28,代码来源:index.ts


示例8: it

 it("sets up the spy", () => {
     _.times(10, () => {
         const expectedResult: number = Math.random();
         const result: any = underTest.andReturn(expectedResult).instance.foo();
         expect(result).toBe(expectedResult);
     });
 });
开发者ID:sh33dafi,项目名称:typescript-mockify,代码行数:7,代码来源:StubbedFunc.spec.ts


示例9: ARGB

export const web = _.flatten(_.times(6, (r) => {
  return _.flatten(_.times(6, (g) => {
    return _.times(6, (b) => {
      return new ARGB(255, r * 51, g * 51, b * 51);
    });
  }));
}));
开发者ID:mmmpa,项目名称:dot_dot_web,代码行数:7,代码来源:constants.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript lodash.toArray函数代码示例发布时间:2022-05-25
下一篇:
TypeScript lodash.throttle函数代码示例发布时间: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