correctly support options with Chance#n method (#38711)

* correctly support options with Chance#n method

* correctly support options with Chance#unique method

* correctly support options with Chance#unique method
This commit is contained in:
Chad Elliott
2019-10-03 15:59:25 -05:00
committed by Ryan Cavanaugh
parent ea511606c9
commit 45780f09bd
2 changed files with 6 additions and 2 deletions

View File

@@ -15,8 +15,10 @@ guid = chance.guid({ version: 4 });
guid = chance.guid({ version: 5 });
const strArr: string[] = chance.n(chance.string, 42);
const strArr2: string[] = chance.n((a) => a.value, 42, { value: 'test' });
const uniqInts: number[] = chance.unique(chance.integer, 99);
const uniqInts2: number[] = chance.unique(a => a.value, 99, { value: 1 });
const currencyPair = chance.currency_pair();
const firstCurrency = currencyPair[0];

View File

@@ -166,13 +166,15 @@ declare namespace Chance {
d100(): number;
guid(options?: { version: 4 | 5 }): string;
hash(opts?: Options): string;
n<T>(generator: () => T, count: number, opts?: Options): T[];
n<T>(generator: () => T, count: number): T[];
n<T, O extends Options>(generator: (options: O) => T, count: number, options: O): T[];
normal(opts?: Options): number;
radio(opts?: Options): string;
rpg(dice: string): number[];
rpg(dice: string, opts?: Options): number[] | number;
tv(opts?: Options): string;
unique<T>(generator: () => T, count: number, opts?: Options): T[];
unique<T>(generator: () => T, count: number): T[];
unique<T, O extends Options>(generator: (options: O) => T, count: number, options: O): T[];
weighted<T>(values: T[], weights: number[]): T;
// "Hidden"