本文整理匯總了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();
}