本文整理汇总了TypeScript中seedrandom.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor(seed : string, verbose: boolean) {
// The generator only cares about its own seed value and its random number generator
this.seed = seed;
this.randGenerator = (seed != '') ? seedrandom(seed) : seedrandom();
if (verbose) {
this.verbose = verbose;
} else {
this.verbose = false
}
}
示例2: _str
beforeEach(() => {
rng = seedrandom('some fixed value');
function _str(len: number) {
let r = '';
const space = 'abcdefghijklmnopqrstuvwxyz0123456789';
for (let i = 0; i < len; i++) {
r += space[Math.floor(rng() * space.length)];
}
return r;
}
// Build test cases.
cases = new Array(numRandomIter)
.fill(0)
.map(() => {
return new Array(Math.floor(rng() * 20 + 5))
.fill(0)
.map(() => _str(rng() * 20 + 3))
.join('/');
});
resetNormalizeCache();
});
示例3: randomKey
export function randomKey() {
const byteseed = new Uint8Array(32)
for (let i = 0; i < 32; i++) {
byteseed[i] = Math.floor(seedrandom()() * 255) + 1
}
const keypair = nacl.sign.keyPair.fromSeed(byteseed)
return new Key(
Base58encode(keypair.publicKey),
Base58encode(keypair.secretKey)
)
}
示例4: getParts
private getParts(id: string, variant: string) {
const variantParts = this._variants[variant]
if (!variantParts) {
throw new Error(
`variant '${variant}' is not supported. Supported variants: ${Object.keys(
this._variants
)}`
)
}
const rng = seedrandom(id)
return this._parts
.map(
(partName: AvatarPart): string => {
const partVariants = variantParts[partName]
return (
partVariants &&
partVariants[Math.floor(rng() * partVariants.length)]
)
}
)
.filter(Boolean)
}
示例5: function
random.seed = function(s) {
state.rng = seedrandom(s);
};
示例6: random
function random(): number {
if (!state.rng) state.rng = seedrandom(state.sessionContext.deviceId);
return state.rng();
}