mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
🤖 Merge PR #44651 update(chance): add missing methods from 1.1 by @peterblazejewicz
- Basics.falsy - Basics.template - test amended - maintainer added - version bumpt see: https://github.com/chancejs/chancejs/compare/1.0.18...1.1.5 Thanks! Co-authored-by: PiotrB <pblazejewicz@appriss.com>
This commit is contained in:
parent
a08ce5ef58
commit
64a00b1f51
@ -143,6 +143,11 @@ char = chance.character({ numeric: true });
|
||||
char = chance.character({ symbols: true });
|
||||
char = chance.character({ pool: 'abcdef', casing: 'lower', alpha: true, numeric: true, symbols: true });
|
||||
|
||||
chance.falsy(); // $ExpectType FalsyType
|
||||
chance.falsy({ pool: [NaN, undefined] }); // $ExpectType FalsyType
|
||||
|
||||
chance.template('{AA###}-{##}'); // $ExpectType string
|
||||
|
||||
let url: string = chance.url();
|
||||
url = chance.url({});
|
||||
url = chance.url({protocol: 'http'});
|
||||
|
||||
12
types/chance/index.d.ts
vendored
12
types/chance/index.d.ts
vendored
@ -1,4 +1,4 @@
|
||||
// Type definitions for Chance 1.0
|
||||
// Type definitions for Chance 1.1
|
||||
// Project: http://chancejs.com
|
||||
// Definitions by: Chris Bowdon <https://github.com/cbowdon>
|
||||
// Brice BERNARD <https://github.com/brikou>
|
||||
@ -6,8 +6,8 @@
|
||||
// Colby M. White <https://github.com/colbywhite>
|
||||
// Zachary Dow <https://github.com/NewDark90>
|
||||
// Jacob Easley <https://github.com/jacobez>
|
||||
// Piotr Błażejewicz <https://github.com/peterblazejewicz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
declare namespace Chance {
|
||||
type Seed = number | string;
|
||||
@ -26,15 +26,23 @@ declare namespace Chance {
|
||||
new (generator: () => any): Chance;
|
||||
}
|
||||
|
||||
type FalsyType = false | null | undefined | 0 | typeof NaN | '';
|
||||
interface FalsyOptions {
|
||||
pool: FalsyType[];
|
||||
}
|
||||
|
||||
interface Chance extends Seeded {
|
||||
// Basics
|
||||
bool(opts?: {likelihood: number}): boolean;
|
||||
character(opts?: Partial<CharacterOptions>): string;
|
||||
/** https://chancejs.com/basics/falsy.html */
|
||||
falsy(ops?: FalsyOptions): FalsyType;
|
||||
floating(opts?: Options): number;
|
||||
integer(opts?: Partial<IntegerOptions>): number;
|
||||
letter(opts?: Options): string;
|
||||
natural(opts?: Options): number;
|
||||
string(opts?: Partial<StringOptions>): string;
|
||||
template(template: string): string;
|
||||
|
||||
// Text
|
||||
paragraph(opts?: Options): string;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user