mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-02-03 23:42:50 +00:00
feat(chance): add missing string/character options (#36548)
This commit is contained in:
parent
7797cfdd1a
commit
3db0acafb2
@ -105,9 +105,28 @@ word = chance.word({length: 10});
|
||||
word = chance.word({capitalize: true});
|
||||
|
||||
let randomString: string = chance.string();
|
||||
randomString = chance.string({pool: 'abcdef', length: 10});
|
||||
randomString = chance.string({pool: 'abcdef'});
|
||||
randomString = chance.string({length: 10});
|
||||
randomString = chance.string({ pool: 'abcdef' });
|
||||
randomString = chance.string({ length: 10 });
|
||||
randomString = chance.string({ casing: 'upper' });
|
||||
randomString = chance.string({ alpha: true });
|
||||
randomString = chance.string({ numeric: true });
|
||||
randomString = chance.string({ symbols: '!@#$' });
|
||||
randomString = chance.string({
|
||||
pool: 'abcdef',
|
||||
length: 10,
|
||||
casing: 'lower',
|
||||
alpha: true,
|
||||
numeric: true,
|
||||
symbols: ')(*&',
|
||||
});
|
||||
|
||||
let char: string = chance.character();
|
||||
char = chance.character({ pool: 'abcdef' });
|
||||
char = chance.character({ casing: 'upper' });
|
||||
char = chance.character({ alpha: true });
|
||||
char = chance.character({ numeric: true });
|
||||
char = chance.character({ symbols: '!@#$' });
|
||||
char = chance.character({ pool: 'abcdef', casing: 'lower', alpha: true, numeric: true, symbols: ')(*&' });
|
||||
|
||||
let url: string = chance.url();
|
||||
url = chance.url({protocol: 'http'});
|
||||
|
||||
11
types/chance/index.d.ts
vendored
11
types/chance/index.d.ts
vendored
@ -31,7 +31,7 @@ declare namespace Chance {
|
||||
interface Chance extends Seeded {
|
||||
// Basics
|
||||
bool(opts?: {likelihood: number}): boolean;
|
||||
character(opts?: Options): string;
|
||||
character(opts?: AtLeastOneKey<CharacterOptions>): string;
|
||||
floating(opts?: Options): number;
|
||||
integer(opts?: AtLeastOneKey<IntegerOptions>): number;
|
||||
letter(opts?: Options): string;
|
||||
@ -197,11 +197,16 @@ declare namespace Chance {
|
||||
capitalize: boolean;
|
||||
}
|
||||
|
||||
interface StringOptions {
|
||||
length: number;
|
||||
interface CharacterOptions {
|
||||
casing: 'upper' | 'lower';
|
||||
pool: string;
|
||||
alpha: boolean;
|
||||
numeric: boolean;
|
||||
symbols: string;
|
||||
}
|
||||
|
||||
type StringOptions = CharacterOptions & { length: number } ;
|
||||
|
||||
interface UrlOptions {
|
||||
protocol: string;
|
||||
domain: string;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user