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


TypeScript random-js.integer函數代碼示例

本文整理匯總了TypeScript中random-js.integer函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript integer函數的具體用法?TypeScript integer怎麽用?TypeScript integer使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了integer函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: function

 return function (engine, locale) {
     const n = integer(min, max)(engine);
     return [...new Array(n).keys()].map(() => {
         const chosenArb = arb ? arb : recursive(array, any, 2);
         return chosenArb.makeGenerator()(engine, locale);
     });
 };
開發者ID:hychen,項目名稱:hycheck,代碼行數:7,代碼來源:collections.ts

示例2: integer

 integer(min: number | undefined, max: number | undefined): number {
     if (!min)
         min = 1;
     if (!max)
         max = min;
     if (max < min)
         throw new Error('minmax');
     return randomjs.integer(min, max)(this.engine);
 }
開發者ID:sbj42,項目名稱:sbj42.github.io,代碼行數:9,代碼來源:random.ts

示例3: rec

 function rec(n: number): Arbitrary<V, RecursiveGenOpts<V, O>> {
     const chance = integer(0, 3)(engine);
     if (n <= 0 || chance === 0) {
         return n === depth ? combinator(arb) : arb;
     }
     else {
         return combinator(rec(n - 1));
     }
 };
開發者ID:hychen,項目名稱:hycheck,代碼行數:9,代碼來源:collections.ts

示例4:

 export function shuffle<T>(array: Array<T>) {
     let n = array.length;
     for (let i = n - 1; i > 0; i=i-1) {
         let j = rand.integer(0, i);
         let tmp = array[i];
         array[i] = array[j];
         array[j] = tmp;
     }
 }
開發者ID:Goita,項目名稱:goita-core-js,代碼行數:9,代碼來源:util.ts

示例5: mutateNode

function mutateNode(keys: string[], random: Random, entity: Entity): Entity {
  const willMutate = random.bool(MUTATE_PERCENTAGE);

  if (!willMutate) {
    return entity;
  }

  const mutationId = random.integer(MIN_SEED, MAX_SEED);
  const mutation = chooseMutation(keys, mutationId, entity);

  return applyMutation(entity, mutation);
}
開發者ID:helix-pi,項目名稱:helix-pi,代碼行數:12,代碼來源:index.ts

示例6: generateEntities

function generateEntities(
  random: Random,
  generationSize: number,
  keys: string[]
): Entity[] {
  const entities = [];

  while (entities.length < generationSize) {
    entities.push(generateEntity(random.integer(MIN_SEED, MAX_SEED), keys));
  }

  return entities;
}
開發者ID:helix-pi,項目名稱:helix-pi,代碼行數:13,代碼來源:index.ts

示例7: function

 return function (engine, locale) {
     function pick(n: number, [[k, x], ...xs]): any {
         return (n <= k) ? x : pick(n - k, xs);
     }
     const total = sum(pool.map(e => e[0]));
     const head = integer(1, total)(engine);
     const result = pick(head, pool);
     if (result instanceof Arbitrary) {
         return result.makeGenerator()(engine, locale);
     }
     else {
         return result;
     };
 };
開發者ID:hychen,項目名稱:hycheck,代碼行數:14,代碼來源:pickers.ts

示例8: integer

 gen: (opts: { min: number }) => (engine) => integer(opts.min, 2)(engine),
開發者ID:hychen,項目名稱:hycheck,代碼行數:1,代碼來源:arbitrary.test.ts

示例9: integer

 randexp.randInt = (from: number, to: number) => {
     return integer(from, to)(engine);
 }
開發者ID:hychen,項目名稱:hycheck,代碼行數:3,代碼來源:value.ts

示例10: integer

export function integer(min: number, max: number): number {
    return Random.integer(min, max)(engine);
}
開發者ID:MPennanti,項目名稱:HungryDragon,代碼行數:3,代碼來源:random.ts


注:本文中的random-js.integer函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。