當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript lodash.times函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。