🤖 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:
Piotr Błażejewicz (Peter Blazejewicz) 2020-05-12 21:58:38 +02:00 committed by GitHub
parent a08ce5ef58
commit 64a00b1f51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 2 deletions

View File

@ -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'});

View File

@ -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;