UNPKG

16.8 kBTypeScriptView Raw
1// Type definitions for faker 5.5
2// Project: http://marak.com/faker.js/
3// Definitions by: Ben Swartz <https://github.com/bensw>,
4// Bas Pennings <https://github.com/basp>,
5// Yuki Kokubun <https://github.com/Kuniwak>,
6// Matt Bishop <https://github.com/mattbishop>,
7// Leonardo Testa <https://github.com/testica>
8// Sebastian Pettersson <https://github.com/TastefulElk>
9// Daniel Montesinos <https://github.com/damonpam>
10// Shinya Ohyanagi <https://github.com/heavenshell>
11// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
12
13declare const fakerStatic: Faker.FakerStatic;
14
15declare namespace Faker {
16 interface FakerStatic {
17 locale: string;
18 setLocale(locale: string): void;
19
20 address: {
21 zipCodeByState(state: string): string;
22 zipCode(format?: string): string;
23 city(format?: number): string;
24 cityPrefix(): string;
25 citySuffix(): string;
26 streetName(): string;
27 streetAddress(useFullAddress?: boolean): string;
28 streetSuffix(): string;
29 streetPrefix(): string;
30 secondaryAddress(): string;
31 county(): string;
32 country(): string;
33 countryCode(alphaCode?: string): string;
34 state(useAbbr?: boolean): string;
35 stateAbbr(): string;
36 latitude(max?: number, min?: number, precision?: number): string;
37 longitude(max?: number, min?: number, precision?: number): string;
38 direction(useAbbr?: boolean): string;
39 cardinalDirection(useAbbr?: boolean): string;
40 ordinalDirection(useAbbr?: boolean): string;
41 nearbyGPSCoordinate(coordinate?: ReadonlyArray<string>, radius?: number, isMetric?: boolean): string[];
42 timeZone(): string;
43 };
44
45 commerce: {
46 color(): string;
47 department(): string;
48 productName(): string;
49 price(min?: number, max?: number, dec?: number, symbol?: string): string;
50 productAdjective(): string;
51 productMaterial(): string;
52 product(): string;
53 productDescription(): string;
54 };
55
56 company: {
57 suffixes(): string[];
58 companyName(format?: number): string;
59 companySuffix(): string;
60 catchPhrase(): string;
61 bs(): string;
62 catchPhraseAdjective(): string;
63 catchPhraseDescriptor(): string;
64 catchPhraseNoun(): string;
65 bsAdjective(): string;
66 bsBuzz(): string;
67 bsNoun(): string;
68 };
69
70 database: {
71 column(): string;
72 type(): string;
73 collation(): string;
74 engine(): string;
75 };
76
77 datatype: {
78 number(max?: number): number;
79 number(options?: { min?: number; max?: number; precision?: number }): number;
80 float(max?: number): number;
81 float(options?: { min?: number; max?: number; precision?: number }): number;
82 datetime(max?: number): Date;
83 datetime(options?: { min?: number; max?: number }): Date;
84 string(length?: number): string;
85 uuid(): string;
86 boolean(): boolean;
87 hexaDecimal(count?: number): string;
88 json(): string;
89 array(length?: number): Array<string | number>;
90 };
91
92 date: {
93 past(years?: number, refDate?: string | Date): Date;
94 future(years?: number, refDate?: string | Date): Date;
95 between(from: string | number | Date, to: string | Date): Date;
96 recent(days?: number, refDate?: string | Date): Date;
97 soon(days?: number, refDate?: string | Date): Date;
98 month(options?: { abbr?: boolean; context?: boolean }): string;
99 weekday(options?: { abbr?: boolean; context?: boolean }): string;
100 };
101
102 fake(str: string): string;
103
104 finance: {
105 account(length?: number): string;
106 accountName(): string;
107 routingNumber(): string;
108 mask(length?: number, parens?: boolean, elipsis?: boolean): string;
109 amount(min?: number, max?: number, dec?: number, symbol?: string): string;
110 transactionType(): string;
111 currencyCode(): string;
112 currencyName(): string;
113 currencySymbol(): string;
114 bitcoinAddress(): string;
115 iban(formatted?: boolean): string;
116 bic(): string;
117 litecoinAddress(): string;
118 creditCardNumber(provider?: string): string;
119 creditCardCVV(): string;
120 ethereumAddress(): string;
121 transactionDescription(): string;
122 };
123
124 git: {
125 branch(): string;
126 commitEntry(options?: { merge: boolean }): string;
127 commitMessage(): string;
128 commitSha(): string;
129 shortSha(): string;
130 };
131
132 hacker: {
133 abbreviation(): string;
134 adjective(): string;
135 noun(): string;
136 verb(): string;
137 ingverb(): string;
138 phrase(): string;
139 };
140
141 helpers: {
142 randomize<T>(array: T[]): T;
143 randomize(): string;
144 slugify(string?: string): string;
145 replaceSymbolWithNumber(string?: string, symbol?: string): string;
146 replaceSymbols(string?: string): string;
147 replaceCreditCardSymbols(string?: string, symbol?: string): string;
148 repeatString(string: string, num?: number): string;
149 regexpStyleStringParse(string: string): string;
150 shuffle<T>(o: T[]): T[];
151 shuffle(): string[];
152 mustache(
153 str: string,
154 data: { [key: string]: string | ((substring: string, ...args: any[]) => string) },
155 ): string;
156 createCard(): Card;
157 contextualCard(): ContextualCard;
158 userCard(): UserCard;
159 createTransaction(): Transaction;
160 };
161
162 image: {
163 image(): string;
164 avatar(): string;
165 imageUrl(width?: number, height?: number, category?: string, randomize?: boolean, https?: boolean): string;
166 abstract(width?: number, height?: number): string;
167 animals(width?: number, height?: number): string;
168 business(width?: number, height?: number): string;
169 cats(width?: number, height?: number): string;
170 city(width?: number, height?: number): string;
171 food(width?: number, height?: number): string;
172 nightlife(width?: number, height?: number): string;
173 fashion(width?: number, height?: number): string;
174 people(width?: number, height?: number): string;
175 nature(width?: number, height?: number): string;
176 sports(width?: number, height?: number): string;
177 technics(width?: number, height?: number): string;
178 transport(width?: number, height?: number): string;
179 dataUri(width?: number, height?: number, color?: string): string;
180 };
181
182 internet: {
183 avatar(): string;
184 email(firstName?: string, lastName?: string, provider?: string): string;
185 exampleEmail(firstName?: string, lastName?: string): string;
186 userName(firstName?: string, lastName?: string): string;
187 protocol(): string;
188 url(): string;
189 domainName(): string;
190 domainSuffix(): string;
191 domainWord(): string;
192 ip(): string;
193 ipv6(): string;
194 userAgent(): string;
195 color(baseRed255?: number, baseGreen255?: number, baseBlue255?: number): string;
196 mac(sep?: string): string;
197 password(len?: number, memorable?: boolean, pattern?: string | RegExp, prefix?: string): string;
198 };
199
200 lorem: {
201 word(length?: number): string;
202 words(num?: number): string;
203 sentence(wordCount?: number, range?: number): string;
204 slug(wordCount?: number): string;
205 sentences(sentenceCount?: number): string;
206 paragraph(sentenceCount?: number): string;
207 paragraphs(paragraphCount?: number, separator?: string): string;
208 text(times?: number): string;
209 lines(lineCount?: number): string;
210 };
211
212 name: {
213 firstName(gender?: number): string;
214 lastName(gender?: number): string;
215 middleName(gender?: number): string;
216 findName(firstName?: string, lastName?: string, gender?: number): string;
217 jobTitle(): string;
218 gender(): string;
219 prefix(): string;
220 suffix(): string;
221 title(): string;
222 jobDescriptor(): string;
223 jobArea(): string;
224 jobType(): string;
225 };
226
227 music: {
228 genre(): string;
229 };
230
231 phone: {
232 phoneNumber(format?: string): string;
233 phoneNumberFormat(phoneFormatsArrayIndex?: number): string;
234 phoneFormats(): string;
235 };
236
237 random: {
238 /** @deprecated faker.random.number is now located in faker.datatype.number */
239 number(max?: number): number;
240 /** @deprecated faker.random.number is now located in faker.datatype.number */
241 number(options?: { min?: number; max?: number; precision?: number }): number;
242 /** @deprecated faker.random.float is now located in faker.datatype.float */
243 float(max?: number): number;
244 /** @deprecated faker.random.float is now located in faker.datatype.float */
245 float(options?: { min?: number; max?: number; precision?: number }): number;
246 arrayElement(): string;
247 arrayElement<T>(array: T[]): T;
248 arrayElement<T>(array: ReadonlyArray<T>): T;
249 arrayElements(count?: number): string[];
250 arrayElements<T>(array: T[], count?: number): T[];
251 arrayElements<T>(array: ReadonlyArray<T>, count?: number): ReadonlyArray<T>;
252 objectElement(object?: { [key: string]: any }, field?: 'key'): string;
253 objectElement<T>(object?: { [key: string]: T }, field?: any): T;
254 /** @deprecated faker.random.uuid is now located in faker.datatype.uuid */
255 uuid(): string;
256 /** @deprecated faker.random.boolean is now located in faker.datatype.boolean */
257 boolean(): boolean;
258 word(type?: string): string;
259 words(count?: number): string;
260 image(): string;
261 locale(): string;
262 alpha(options?: { count?: number; upcase?: boolean }): string;
263 alphaNumeric(count?: number): string;
264 /** @deprecated faker.random.hexaDecimal is now located in faker.datatype.hexaDecimal */
265 hexaDecimal(count?: number): string;
266 };
267
268 system: {
269 fileName(): string;
270 commonFileName(ext?: string): string;
271 mimeType(): string;
272 commonFileType(): string;
273 commonFileExt(): string;
274 fileType(): string;
275 fileExt(mimeType?: string): string;
276 directoryPath(): string;
277 filePath(): string;
278 semver(): string;
279 };
280
281 time: {
282 recent(): number;
283 recent(outputType: 'unix'): number;
284 recent(outputType: 'abbr' | 'wide'): string;
285 };
286
287 seed(value: number): void;
288 seedValue?: number;
289
290 vehicle: {
291 vehicle(): string;
292 manufacturer(): string;
293 model(): string;
294 type(): string;
295 fuel(): string;
296 vin(): string;
297 color(): string;
298 };
299
300 unique<T extends (...args: any) => any>(
301 method: T,
302 args?: Parameters<T>,
303 opts?: { maxTime?: number; maxRetries?: number },
304 ): ReturnType<T>;
305 }
306
307 interface Card {
308 name: string;
309 username: string;
310 email: string;
311 address: FullAddress;
312 phone: string;
313 website: string;
314 company: Company;
315 posts: Post[];
316 accountHistory: string[];
317 }
318
319 interface FullAddress {
320 streetA: string;
321 streetB: string;
322 streetC: string;
323 streetD: string;
324 city: string;
325 state: string;
326 county: string;
327 zipcode: string;
328 geo: Geo;
329 }
330
331 interface Geo {
332 lat: string;
333 lng: string;
334 }
335
336 interface Company {
337 name: string;
338 catchPhrase: string;
339 bs: string;
340 }
341
342 interface Post {
343 words: string;
344 sentence: string;
345 sentences: string;
346 paragraph: string;
347 }
348
349 interface ContextualCard {
350 name: string;
351 username: string;
352 avatar: string;
353 email: string;
354 dob: Date;
355 phone: string;
356 address: Address;
357 website: string;
358 company: Company;
359 }
360
361 interface Address {
362 street: string;
363 suite: string;
364 city: string;
365 state: string;
366 zipcode: string;
367 geo: Geo;
368 }
369
370 interface UserCard {
371 name: string;
372 username: string;
373 email: string;
374 address: Address;
375 phone: string;
376 website: string;
377 company: Company;
378 }
379
380 interface Transaction {
381 amount: string;
382 date: Date;
383 business: string;
384 name: string;
385 type: string;
386 account: string;
387 }
388}
389
390declare module 'faker' {
391 export = fakerStatic;
392}
393
394declare module 'faker/locale/az' {
395 export = fakerStatic;
396}
397
398declare module 'faker/locale/ar' {
399 export = fakerStatic;
400}
401
402declare module 'faker/locale/cz' {
403 export = fakerStatic;
404}
405
406declare module 'faker/locale/de' {
407 export = fakerStatic;
408}
409
410declare module 'faker/locale/de_AT' {
411 export = fakerStatic;
412}
413
414declare module 'faker/locale/de_CH' {
415 export = fakerStatic;
416}
417
418declare module 'faker/locale/en' {
419 export = fakerStatic;
420}
421
422declare module 'faker/locale/en_AU' {
423 export = fakerStatic;
424}
425
426declare module 'faker/locale/en_AU_ocker' {
427 export = fakerStatic;
428}
429
430declare module 'faker/locale/en_BORK' {
431 export = fakerStatic;
432}
433
434declare module 'faker/locale/en_CA' {
435 export = fakerStatic;
436}
437
438declare module 'faker/locale/en_GB' {
439 export = fakerStatic;
440}
441
442declare module 'faker/locale/en_IE' {
443 export = fakerStatic;
444}
445
446declare module 'faker/locale/en_IND' {
447 export = fakerStatic;
448}
449
450declare module 'faker/locale/en_US' {
451 export = fakerStatic;
452}
453
454declare module 'faker/locale/en_ZA' {
455 export = fakerStatic;
456}
457
458declare module 'faker/locale/es' {
459 export = fakerStatic;
460}
461
462declare module 'faker/locale/es_MX' {
463 export = fakerStatic;
464}
465
466declare module 'faker/locale/fa' {
467 export = fakerStatic;
468}
469
470declare module 'faker/locale/fi' {
471 export = fakerStatic;
472}
473
474declare module 'faker/locale/fr' {
475 export = fakerStatic;
476}
477
478declare module 'faker/locale/fr_CA' {
479 export = fakerStatic;
480}
481
482declare module 'faker/locale/fr_CH' {
483 export = fakerStatic;
484}
485
486declare module 'faker/locale/ge' {
487 export = fakerStatic;
488}
489
490declare module 'faker/locale/id_ID' {
491 export = fakerStatic;
492}
493
494declare module 'faker/locale/it' {
495 export = fakerStatic;
496}
497
498declare module 'faker/locale/ja' {
499 export = fakerStatic;
500}
501
502declare module 'faker/locale/ko' {
503 export = fakerStatic;
504}
505
506declare module 'faker/locale/nb_NO' {
507 export = fakerStatic;
508}
509
510declare module 'faker/locale/nep' {
511 export = fakerStatic;
512}
513
514declare module 'faker/locale/nl' {
515 export = fakerStatic;
516}
517
518declare module 'faker/locale/nl_BE' {
519 export = fakerStatic;
520}
521
522declare module 'faker/locale/pl' {
523 export = fakerStatic;
524}
525
526declare module 'faker/locale/pt_BR' {
527 export = fakerStatic;
528}
529
530declare module 'faker/locale/pt_PT' {
531 export = fakerStatic;
532}
533
534declare module 'faker/locale/ro' {
535 export = fakerStatic;
536}
537
538declare module 'faker/locale/ru' {
539 export = fakerStatic;
540}
541
542declare module 'faker/locale/sk' {
543 export = fakerStatic;
544}
545
546declare module 'faker/locale/sv' {
547 export = fakerStatic;
548}
549
550declare module 'faker/locale/tr' {
551 export = fakerStatic;
552}
553
554declare module 'faker/locale/uk' {
555 export = fakerStatic;
556}
557
558declare module 'faker/locale/vi' {
559 export = fakerStatic;
560}
561
562declare module 'faker/locale/zh_CN' {
563 export = fakerStatic;
564}
565
566declare module 'faker/locale/zh_TW' {
567 export = fakerStatic;
568}