本文整理匯總了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);
});
};
示例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);
}
示例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));
}
};
示例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;
}
}
示例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);
}
示例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;
}
示例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;
};
};
示例8: integer
gen: (opts: { min: number }) => (engine) => integer(opts.min, 2)(engine),
示例9: integer
randexp.randInt = (from: number, to: number) => {
return integer(from, to)(engine);
}
示例10: integer
export function integer(min: number, max: number): number {
return Random.integer(min, max)(engine);
}