1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | declare namespace Chance {
|
7 |
|
8 | interface ChanceStatic {
|
9 | (): Chance
|
10 | (seed: number): Chance
|
11 | (generator: () => any): Chance
|
12 |
|
13 | new(): Chance;
|
14 | new(seed: number): Chance;
|
15 | new(generator: () => any): Chance;
|
16 | }
|
17 |
|
18 | interface Chance {
|
19 |
|
20 |
|
21 | bool(opts?: Options): boolean;
|
22 | character(opts?: Options): string;
|
23 | floating(opts?: Options): number;
|
24 | integer(opts?: Options): number;
|
25 | natural(opts?: Options): number;
|
26 | string(opts?: Options): string;
|
27 |
|
28 |
|
29 | paragraph(opts?: Options): string;
|
30 | sentence(opts?: Options): string;
|
31 | syllable(opts?: Options): string;
|
32 | word(opts?: Options): string;
|
33 |
|
34 |
|
35 | age(opts?: Options): number;
|
36 | birthday(): Date;
|
37 | birthday(opts?: Options): Date|string;
|
38 | cpf(): string;
|
39 | first(opts?: Options): string;
|
40 | last(opts?: Options): string;
|
41 | name(opts?: Options): string;
|
42 | name_prefix(opts?: Options): string;
|
43 | name_suffix(opts?: Options): string;
|
44 | prefix(opts?: Options): string;
|
45 | ssn(opts?: Options): string;
|
46 | suffix(opts?: Options): string;
|
47 |
|
48 |
|
49 | android_id(): string;
|
50 | apple_token(): string;
|
51 | bb_pin(): string;
|
52 | wp7_anid(): string;
|
53 | wp8_anid2(): string;
|
54 |
|
55 |
|
56 | color(opts?: Options): string;
|
57 | domain(opts?: Options): string;
|
58 | email(opts?: Options): string;
|
59 | fbid(): string;
|
60 | google_analytics(): string;
|
61 | hashtag(): string;
|
62 | ip(): string;
|
63 | ipv6(): string;
|
64 | klout(): string;
|
65 | tld(): string;
|
66 | twitter(): string;
|
67 | url(opts?: Options): string;
|
68 |
|
69 |
|
70 | address(opts?: Options): string;
|
71 | altitude(opts?: Options): number;
|
72 | areacode(): string;
|
73 | city(): string;
|
74 | coordinates(opts?: Options): string;
|
75 | country(opts?: Options): string;
|
76 | depth(opts?: Options): number;
|
77 | geohash(opts?: Options): string;
|
78 | latitude(opts?: Options): number;
|
79 | longitude(opts?: Options): number;
|
80 | phone(opts?: Options): string;
|
81 | postal(): string;
|
82 | province(opts?: Options): string;
|
83 | state(opts?: Options): string;
|
84 | street(opts?: Options): string;
|
85 | zip(opts?: Options): string;
|
86 |
|
87 |
|
88 | ampm(): string;
|
89 | date(): Date;
|
90 | date(opts: DateOptions): Date|string;
|
91 | hammertime(): number;
|
92 | hour(opts?: Options): number;
|
93 | millisecond(): number;
|
94 | minute(): number;
|
95 | month(): string;
|
96 | month(opts: Options): Month;
|
97 | second(): number;
|
98 | timestamp(): number;
|
99 | year(opts?: Options): string;
|
100 |
|
101 |
|
102 | cc(opts?: Options): string;
|
103 | cc_type(): string;
|
104 | cc_type(opts: Options): string|CreditCardType;
|
105 | currency(): Currency;
|
106 | currency_pair(): [ Currency, Currency ];
|
107 | dollar(opts?: Options): string;
|
108 | exp(): string;
|
109 | exp(opts: Options): string|CreditCardExpiration;
|
110 | exp_month(opts?: Options): string;
|
111 | exp_year(opts?: Options): string;
|
112 |
|
113 |
|
114 | capitalize(str: string): string;
|
115 | mixin(desc: MixinDescriptor): any;
|
116 | pad(num: number, width: number, padChar?: string): string;
|
117 | pick<T>(arr: T[]): T;
|
118 | pick<T>(arr: T[], count: number): T[];
|
119 | set: Setter;
|
120 | shuffle<T>(arr: T[]): T[];
|
121 |
|
122 |
|
123 | d4(): number;
|
124 | d6(): number;
|
125 | d8(): number;
|
126 | d10(): number;
|
127 | d12(): number;
|
128 | d20(): number;
|
129 | d30(): number;
|
130 | d100(): number;
|
131 | guid(): string;
|
132 | hash(opts?: Options): string;
|
133 | n<T>(generator: () => T, count: number, opts?: Options): T[];
|
134 | normal(opts?: Options): number;
|
135 | radio(opts?: Options): string;
|
136 | rpg(dice: string): number[];
|
137 | rpg(dice: string, opts?: Options): number[]|number;
|
138 | tv(opts?: Options): string;
|
139 | unique<T>(generator: () => T, count: number, opts?: Options): T[];
|
140 | weighted<T>(values: T[], weights: number[]): T;
|
141 |
|
142 | // "Hidden"
|
143 | cc_types(): CreditCardType[];
|
144 | mersenne_twister(seed?: number): any; // API return type not defined in docs
|
145 | months(): Month[];
|
146 | name_prefixes(): Name[];
|
147 | provinces(): Name[];
|
148 | states(): Name[];
|
149 | street_suffix(): Name;
|
150 | street_suffixes(): Name[];
|
151 | }
|
152 |
|
153 | // A more rigorous approach might be to produce
|
154 | // the correct options interfaces for each method
|
155 | interface Options { [id: string]: any; }
|
156 |
|
157 | interface DateOptions {
|
158 | string?: boolean;
|
159 | american?: boolean;
|
160 | year?: number;
|
161 | month?: number;
|
162 | day?: number;
|
163 | }
|
164 |
|
165 | interface Month {
|
166 | name: string;
|
167 | short_name: string;
|
168 | numeric: string;
|
169 | }
|
170 |
|
171 | interface CreditCardType {
|
172 | name: string;
|
173 | short_name: string;
|
174 | prefix: string;
|
175 | length: number;
|
176 | }
|
177 |
|
178 | interface Currency {
|
179 | code: string;
|
180 | name: string;
|
181 | }
|
182 |
|
183 | interface CreditCardExpiration {
|
184 | month: string;
|
185 | year: string;
|
186 | }
|
187 |
|
188 | interface MixinDescriptor { [id: string]: () => any; }
|
189 |
|
190 | interface Setter {
|
191 | (key: 'firstNames', values: string[]): any;
|
192 | (key: 'lastNames', values: string[]): any;
|
193 | (key: 'provinces', values: string[]): any;
|
194 | (key: 'us_states_and_dc', values: string[]): any;
|
195 | (key: 'territories', values: string[]): any;
|
196 | (key: 'armed_forces', values: string[]): any;
|
197 | (key: 'street_suffixes', values: string[]): any;
|
198 | (key: 'months', values: string[]): any;
|
199 | (key: 'cc_types', values: string[]): any;
|
200 | (key: 'currency_types', values: string[]): any;
|
201 | <T>(key: string, values: T[]): any;
|
202 | }
|
203 |
|
204 | interface Name {
|
205 | name: string;
|
206 | abbreviation: string;
|
207 | }
|
208 | }
|
209 |
|
210 |
|
211 | declare var chance: Chance.Chance;
|
212 | declare var Chance: Chance.ChanceStatic;
|
213 |
|
214 |
|
215 | declare module 'chance' {
|
216 | interface ExportedChance extends Chance.ChanceStatic {
|
217 | Chance: ExportedChance;
|
218 | }
|
219 | var Chance: ExportedChance;
|
220 |
|
221 | export = Chance;
|
222 | }
|