-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathfaker.js.javascript.txt
495 lines (407 loc) · 25 KB
/
faker.js.javascript.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
┏━━━━━━━━━━━━━━┓
┃ FAKER.JS ┃
┗━━━━━━━━━━━━━━┛
ALTERNATIVES ==> # - faker.js (prefered)
# - chance.js (prefered under some circumstances, really close match)
# - advantages over faker.js:
# - can customize random source
# - has weighted array elements picking
# - has (important): time-related, credit card-related, animal, altitude|depth
# - has (less important): age, birthday, gender, hashtag
# - disadvantages over faker.js:
# - no real localization
# - no templating
# - does not have (important): countryCode, image.dataUri, image,
# bank-accounts-related, username, password, filename|path|MIME-related, product-related
# - does not have (less important): MAC, useragent, catch phrases
# - casual:
# - Node only
# - not well maintained, less high-profile
VERSION ==> #5.5.3
#Node/Browser
#Generates random data matching specific type or category
┌──────────┐
│ CORE │
└──────────┘
FAKER.*.*() #Returns a random VAL according to a specific category.
FAKER.random.word() #Returns one of:
# - address.country|state|county|streetSuffix()
# - commerce.color|productName|product|productAdjective|productMaterial|department()
# - company.catchPhraseAdjective|catchPhraseDescriptor|catchPhraseNoun|bsAdjective|bsBuzz|bsNoun()
# - finance.accountName|transactionType|currencyName()
# - hacker.abbreviation|adjective|noun|verb|ingverb()
# - name.jobDescriptor|jobArea|jobType()
FAKER.random.words([NUM]) #Returns NUM (def: random from 1 to 3) FAKER.random.word() space-delimited
┌───────────────┐
│ TEMPLATES │
└───────────────┘
TEMPLATE #STR which can contain template {{NAME.FUNC[(...)]}} which will be replaced by FAKER.NAME.FUNC(...)
FAKER.fake('TEMPLATE')->STR #
FAKER.helpers.
mustache(STR, OBJ)->STR #Underlying method used. Uses STR.replace() not Mustache
FAKER.helpers. #Replaces:
replaceSymbolWithNumber # - '#' (or CHAR) by [0-9]
(STR[, 'CHAR'])->STR # - '!' by [2-9]
#Leaves rest as is
FAKER.helpers.replaceSymbols(STR) #Replaces:
->STR # - "#" by [0-9]
# - "?" by [A-Z]
# - "*" by [0-9A-Z]
#Leaves rest as is
┌──────────────────┐
│ LOCALIZATION │
└──────────────────┘
FAKER.locale #LANG (def: 'en'). Many are supported
FAKER.localeFallback #LANG (def: 'en')
FAKER.locales.LANG #OBJ containing locale data
require('faker/locale/LANG') #Same as require('faker') but does not require all possible FAKER.locales.LANG
->FAKER #(which take quite some memory)
FAKER.random.locale() #Random LANG
┌─────────────┐
│ HELPERS │
└─────────────┘
FAKER.helpers.slugify(STR)->STR #Only keep [:alnum:]._- and replace space by -
FAKER.helpers.createCard()
FAKER.helpers.contextualCard()
FAKER.helpers.userCard()
FAKER.helpers.createTransaction() #Create fake OBJ with combinations of other methods
┌────────────┐
│ RANDOM │
└────────────┘
FAKER.mersenne.rand([MAX, MIN]) #NUM between MIN-MAX (def: 0-32768) used internally for randomness
FAKER.mersenne.seed(NUM) #Changes seed (def: current microsec)
FAKER.mersenne.seed_array(NUM_ARR)#Same
FAKER.random.alpha(OPTS) #STR made of [a-z]
#OPTS:
# - count NUM (def: 1)
# - upcase BOOL (def: false)
# - bannedChars STR_ARR
FAKER.random.alphaNumeric #STR made of [0-9a-z]
([NUM[, OPTS]]) #NUM is length (def: 1)
#OPTS:
# - bannedChars STR_ARR
FAKER.random.arrayElement(ARR)
->VAL
FAKER.helpers.randomize(ARR)->VAL #Returns random element
FAKER.random.arrayElements
(ARR[, NUM])->ARR2 #Returns NUM random elements
FAKER.random.objectElement
(OBJ)->VAL #Returns random property value
FAKER.random.objectElement
(OBJ, 'key')->VAL #Returns random property key
FAKER.helpers.shuffle(ARR)->ARR #
┌──────────────┐
│ DATATYPE │
└──────────────┘
FAKER.datatype.boolean()->BOOL #true|false
FAKER.datatype.number([MAX|OPTS]) #OPTS:
->NUM # - min NUM (def: 0)
# - max NUM (def: 99999)
# - precision NUM (def: 1) (use 1e-300 to remove this): removes modulo
FAKER.datatype.float([MAX|OPTS])
->NUM #Same but def OPTS.precision 0.01
FAKER.datatype.hexaDecimal([NUM]) #'0xA'
#NUM is length (def: 1)
FAKER.datatype.uuid() #UUIDv4
FAKER.datatype.string([NUM]) #STR made of ASCII visible characters except space and ~
#NUM is length (def: 10)
FAKER.datatype.array([NUM]) #ARR of mixed BOOL|STR|NUM
#NUM is length (def: 10)
FAKER.datatype.json() #'JSON' of an OBJ with several BOOL|STR|NUM properties
FAKER.datatype.datetime #DATE
([MAX|OPTS]) #OPTS:
# - min DATE2 (def: 1990-01-01)
# - max DATE3 (def: 2100-01-01)
┌──────────┐
│ DATE │
└──────────┘
FAKER.date.between
(DATE[_STR], DATE2[_STR]) #DATE3
FAKER.date.betweens #DATE3_ARR
(DATE[_STR], DATE2[_STR][, NUM]) #NUM is length (def: 3)
FAKER.date.past|future #DATE
([NUM][, DATE2[_STR]]) #NUM is number of years behind|ahead (def: 1)
#DATE2 is reference (def: now)
FAKER.date.recent([NUM]) #DATE
#NUM is number of days behind
FAKER.date.soon([NUM][, DATE2]) #DATE
#NUM is number of days ahead, def DATE2 is now
FAKER.date.month([OPTS]) #'January'
#OPTS: abbr BOOL (def: false): 'Jan'
FAKER.date.weekday([OPTS]) #'Thursday'
#OPTS: abbr BOOL (def: false): 'Thu'
┌──────────┐
│ TIME │
└──────────┘
FAKER.time.recent(['TYPE']) #Current time
#TYPE can be:
# - 'unix' (def): DATE_NUM
# - 'wide': '17:21:45 GMT+0200 (Central European Summer Time)'
# - 'abbr': '5:22:00 PM'
┌───────────┐
│ LOREM │
└───────────┘
FAKER.lorem.text() #Randomly calls FAKER.lorem.word[s]|sentence[s]|paragraph[s]|lines()
FAKER.lorem.word() #Random latin word
FAKER.lorem.words([NUM]) #NUM (def: 3) times word(), space-delimited
FAKER.lorem.slug([NUM]) #Same as FAKER.lorem.words() but slugified
FAKER.lorem.sentence([NUM]) #Same but:
# - NUM default is random 3 to 10
# - starts with uppercase, ends with period
FAKER.lorem.sentences
([NUM][, 'SEPARATOR']) #NUM (def: random 2 to 6) times sentence(), SEPARATOR-delimited (def: ' ')
FAKER.lorem.paragraph([NUM]) #Same as sentences(NUM + random(1,3))
#Def NUM: 3
FAKER.lorem.paragraphs
([NUM][, 'SEPARATOR']) #NUM (def: 3) times paragraph(), SEPARATOR-delimited (def: newline)
FAKER.lorem.lines([NUM]) #NUM (def: random 1 to 5) times sentences(), newline-delimited
┌──────────┐
│ NAME │
└──────────┘
FAKER.name.findName(['FIRST_NAME']#Retuns [sometimes prefix()] + firstName() + lastName() + [sometimes suffix()]
[, 'LAST_NAME'][, GENDER]) #
FAKER.name.firstName([GENDER]) #"Manuela"
#GENDER is 0 male, 1 female
FAKER.name.lastName([GENDER]) #"Nader"
FAKER.name.middleName([GENDER]) #"Genaddiesvich"
FAKER.name.prefix([GENDER]) #'Dr.|Miss|...'
FAKER.name.suffix() #'Sr.|II|...'
FAKER.name.gender([BOOL]) #If BOOL false (def), many possible
FAKER.name.title|jobTitle() #'Senior Solutions Analyst' (jobDescriptor() + jobArea() + jobType())
FAKER.name.jobDescriptor() #'Senior'
FAKER.name.jobArea() #'Solutions'
FAKER.name.jobType() #'Analyst'
┌────────────┐
│ ANIMAL │
└────────────┘
FAKER.animal.dog|cat|snake|bear|
lion|cetacean|horse|bird|cow|
fish|crocodilia|insect|rabbit() #"Whale|Dolphin|..."
FAKER.animal.type() #"dog|cat|..."
┌───────────┐
│ PHONE │
└───────────┘
FAKER.phone.phoneFormats() #Phone PATTERN, e.g. '(###) ###-####'
FAKER.phone.phoneNumber([PATTERN])#Same but using FAKER.helpers.replaceSymbolWithNumber()
FAKER.phone.phoneNumberFormat(NUM)#Same but using FORMAT with hard-coded index from builtin list.
┌─────────────┐
│ ADDRESS │
└─────────────┘
FAKER.address.country() #"France"
FAKER.address.countryCode() #"FR"
FAKER.address.state([BOOL]) #"Oregon"|"Aquitaine"|...
#If true, uses stateAbbr()
FAKER.address.stateAbbr() #"MN"
FAKER.address.county() #"Bedfordshire"
FAKER.address.city #"Shanellburgh"
(['TEMPLATE'|NUM]) #NUM can be (def any of them):
# - 0: '{{address.cityPrefix}} {{name.firstName}} {{address.citySuffix}}'
# - 1: '{{address.cityPrefix}} {{name.firstName}}'
# - 2: '{{name.firstName}} {{address.citySuffix}}'
# - 3: '{{name.lastName}} {{address.citySuffix}}'
FAKER.address.cityPrefix() #"New|Port|West|..."
FAKER.address.citySuffix() #"view|side|port|..."
FAKER.address.cityName() #"Paris|..."
FAKER.address.streetAddress #"5606 Kuhic Summit" (zipCode() + streetName())
([BOOL]) #If true, adds secondaryAddress()
FAKER.address.zipCode([STR]) #"0124"
#Uses FAKER.helpers.replaceSymbols()
FAKER.address.zipCodeByState(STR) #"0124". Same but length might change depending on state STR
FAKER.address.streetName() #"Kunde Union" (firstName|lastName() + streetSuffix())
FAKER.address.streetPrefix() #"Passage|Rue|..."
FAKER.address.streetSuffix() #"Way|Green|Wall|de Provence|..."
FAKER.address.secondaryAddress() #"Apt. NUM"|"Suite NUM"|...
FAKER.address.latitude|longitude
([MAX][, MIN]) #NUM
FAKER.address.direction([BOOL]) #'North|East|South|West|Northeast|...'
#If true, 'N|E|...'
FAKER.address.
cardinalDirection([BOOL]) #Same but only 'North|East|South|West'
FAKER.address.
ordinalDirection([BOOL]) #Same but only 'NorthEast|...'
FAKER.nearbyGPSCoordinate #ARR[2] is latitude|longitude NUM
([ARR[, NUM[, BOOL]]])->ARR2 #Returns random coordinate within NUM (def: 10) miles (km if BOOL true)
┌───────────┐
│ IMAGE │
└───────────┘
FAKER.image.dataUri #"data:image/svg+xml;charset=UTF-8,..."
(WIDTH, HEIGHT) #SVG image (as data URI) showing gray rectangle with dimension written in corner.
FAKER.image|internet.avatar() #"https://s3.amazonaws.com/uifaces/faces/twitter/gonzalorobaina/128.jpg"
FAKER.image.imageUrl #"http://placeimg.com/WIDTH/HEIGHT[/CATEGORY]"
([WIDTH][, HEIGHT][, 'CATEGORY'] #Def WIDTH|HEIGHT: 640|480
[, BOOL][, BOOL2]) #If BOOL true, adds random query variable to bust cache
#If BOOL2 true, use "https:"
FAKER.image|random.image
([WIDTH][, HEIGHT][, BOOL]) #Same only within categories below
FAKER.image.abstract(...)
FAKER.image.animals(...)
FAKER.image.business(...)
FAKER.image.cats(...)
FAKER.image.city(...)
FAKER.image.food(...)
FAKER.image.fashion(...)
FAKER.image.nature(...)
FAKER.image.nightlife(...)
FAKER.image.people(...)
FAKER.image.sports(...)
FAKER.image.technics(...)
FAKER.image.transport(...) #Same within specific category
FAKER.unsplash.imageUrl|image|
buildings|food|nature|objects|
people|technology(...) #Same but with Unsplash
FAKER.lorempixel.imageUrl|image|
animals|business|cats|city|
fashion|food|nature|nightlife|
people|sports|technics|
transport(...) #Same with but with lorempixel
FAKER.lorempicsum.imageUrl #Same but with lorempicsum
([WIDTH][, HEIGHT][, BOOL] #BOOL is grayscale (def: false)
[, NUM][, NUM2]) #NUM is blur (def: none)
#NUM2 is random seed
┌─────────────┐
│ FINANCE │
└─────────────┘
FAKER.finance.account([NUM]) #"13263160"
#NUM is length (def: 8)
FAKER.finance.mask #"1731"
([NUM][, BOOL][, BOOL2]) #NUM is length (def: 4). BOOL true (def: false) is "(1731)". BOOL2 true (def: false) is "...1731"
FAKER.finance.accountName() #"Home Loan Account"
FAKER.finance.amount(...[, BOOL]) #"$207.39". Same as FAKER.commerce.price()
#If BOOL true (def: false), use toLocalString()
FAKER.finance.transactionType() #"deposit|invoice|..."
FAKER.finance.currencyCode() #"USD"
FAKER.finance.currencyName() #"Gibraltar Pound"
FAKER.finance.currencySymbol() #"$"
FAKER.finance.creditCardNumber #"5450-5495-7754-6296"
(["PROVIDER"]) #PROVIDER can be american_express|diners_club|discover|instapayment|jcb|laser|maestro|mastercard|solo|switch|visa or custom STR with "#"
FAKER.finance.creditCardCVV() #"287"
FAKER.finance.iban #"VG5035164080892153032160"
([BOOL, ['COUNTRY']]) #If BOOL true (def: false), add whitespaces
FAKER.finance.bic() #"ENJOTKY1"
FAKER.finance.routingNumber() #"715473799"
FAKER.finance.bitcoinAddress() #"1REDI9HX9IJK496TXU1A71JWEEZK"
FAKER.finance.litecoinAddress() #"3duoBfZ7NuBbHLJ2A56RiewXeCf"
FAKER.finance.ethereumAddress() #"0xd08c6bd9c1bab1d8978be42fcdbbd837d2f4aab6"
┌──────────────┐
│ INTERNET │
└──────────────┘
FAKER.internet.userName
(['FIRST_NAME'][, 'LAST_NAME']) #"Abdiel_Hegmann19" (uses FAKER.name.firstName|lastName())
FAKER.internet.email
(['FIRST_NAME'][, 'LAST_NAME']
[, 'DOMAIN']) #"[email protected]" (uses FAKER.internet.userName())
FAKER.internet.exampleEmail
(['FIRST_NAME'][, 'LAST_NAME']) #"[email protected]" (uses FAKER.internet.email())
FAKER.internet.password #"cTGkHU6610zwRFE"
([NUM][, BOOL][, REGEXP][, STR]) #NUM is length (def: 15)
#If BOOL true (def: false): lowercase and alternates between vowels and consonants
#REGEXP only works when BOOL false
#STR is prepended
FAKER.internet.url() #"https://maybelle.info" (protocol() + domainName())
FAKER.internet.protocol() #"http|https"
FAKER.internet.domainName() #"maybelle.info" (domainWord() + domainSuffix())
FAKER.internet.domainWord() #"maybelle" (uses FAKER.name.firstName())
FAKER.internet.domainSuffix() #"info"
FAKER.internet.httpMethod() #'GET|POST|...'
FAKER.internet.port() #NUM from 0-65535
FAKER.internet.ip() #"17.220.52.253"
FAKER.internet.ipv6() #"cb2b:60cb:d4f4:b165:1def:88de:f817:d945"
FAKER.internet.mac() #"dc:d5:db:0f:a3:3c"
FAKER.internet.userAgent() #"Mozilla/5.0 (Windows; U; Windows NT 5.2) AppleWebKit/532.2.2 (KHTML, like Gecko) Chrome/30.0.822.0 Safari/532.2.2"
FAKER.internet.color #"#3e3c2d"
([RED][, GREEN][, BLUE]) #REF|GREEN|BLUE (def: 0) contributes at 50%
┌────────────┐
│ SYSTEM │
└────────────┘
FAKER.system.directoryPath() #'/opt/bin'
FAKER.system.filePath() #'/opt/bin/FILE.EXT' (using system.fileName())
FAKER.system.fileName() #'FILE.EXT' (using random.words() and system.fileExt())
FAKER.system.commonFileName
(['EXT']) #'FILE.EXT' (using random.words() and system.commonFileExt())
FAKER.system.mimeType() #'MIME'
FAKER.system.fileType() #First part of 'MIME'
FAKER.system.commonFileType() #Same but only with common MIMEs
FAKER.system.fileExt([MIME]) #'js'
FAKER.system.commonFileExt() #Same but only with common MIMEs
FAKER.system.semver() #'NUM.NUM.NUM'
┌──────────────┐
│ DATABASE │
└──────────────┘
FAKER.database.engine() #"CSV|InnoDB|..."
FAKER.database.type() #"float|datetime|..."
FAKER.database.column() #"id|createdAt|email|..."
FAKER.database.collation() #"utf8_unicode_ci"
┌──────────────┐
│ COMMERCE │
└──────────────┘
FAKER.commerce.color() #"white|red|..."
FAKER.commerce.price #"NUM2.00"
([MIN][, MAX][, NUM][, STR]) #Def MIN|MAX: 0|1000
#NUM is number of decimals (def: 2)
#STR is currency (def: '')
FAKER.commerce.productName() #"Licensed Granite Shoes" (productAdjective() + product() + productMaterial())
FAKER.commerce.product() #"Shoes"
FAKER.commerce.productAdjective() #"Refined|Practical|..."
FAKER.commerce.productMaterial() #"Cotton"
FAKR.commerce.productDescription()#"The Football Is Good For Training And Recreational Purposes"
FAKER.commerce.department() #"Kids|Jewelery|..."
┌─────────────┐
│ COMPANY │
└─────────────┘
FAKER.company.companyName #"Willms Inc"
(['TEMPLATE'|NUM]) #NUM can be (def any of them):
# - 0: '{{name.lastName}} {{compamy.companySuffix}}'
# - 1: '{{name.lastName}} - {{name.lastName}}'
# - 2: '{{name.lastName}}, {{name.lastName}} and {{name.lastName}}'
FAKER.company.companySuffix() #"Inc"
FAKER.company.catchPhrase() #"Reverse-engineered asynchronous superstructure"
#(catchPhraseAdjective() + catchPhraseDescriptor() + catchPheaseNoun())
FAKER.company.
catchPhraseAdjective() #"Reverse-engineered"
FAKER.company.
catchPhraseDescriptor() #"asynchronous"
FAKER.company.catchPhraseNoun() #"superstructure"
FAKER.company.bs() #"enterprise orchestrate functionalities"
FAKER.company.
bsAjective|Buzz|Noun() #Similar as FAKER.company.catchPhrase*()
┌───────────┐
│ MUSIC │
└───────────┘
FAKER.music.genre() #"Hip Hop"
┌─────────────┐
│ VEHICLE │
└─────────────┘
FAKER.vehicle.vehicle(...) #
FAKER.vehicle.manufacturer(...) #
FAKER.vehicle.model(...) #
FAKER.vehicle.type(...) #
FAKER.vehicle.fuel(...) #
FAKER.vehicle.vrm(...) #
FAKER.vehicle.bicycle(...) #
FAKER.vehicle.vin(...) #
FAKER.vehicle.color(...) #
┌────────────┐
│ HACKER │
└────────────┘
FAKER.hacker.phrase() #"I'll back up the optical AI pixel, that should driver the SSL transmitter!" (uses the five below)
FAKER.hacker.abbreviation() #"HTTP|SMTP|..."
FAKER.hacker.adjective() #"multi-byte|primary|..."
FAKER.hacker.noun() #"port|system|..."
FAKER.hacker.verb() #"bypass|connect|..."
FAKER.hacker.ingverb() #"calculating|backing up|..."
┌─────────┐
│ GIT │
└─────────┘
FAKER.git.shortSha() #'7231014'
FAKER.git.commitSha() #'924b6976407b4a8370a0dfe842f5485cdbf5b928'
FAKER.git.branch() #"port-entry"
#"STR-STR2" using faker.noun|verb()
FAKER.git.commitMessage() #"calculate haptic transmitter"
#"STR STR2 STR3" using faker.verb|adjective|noun()
FAKER.git.commitEntry([OBJ]) #`commit 1929b56dfaebd440988f4f13d421ec4c79301f23
#Author: Emilio Farrell <[email protected]>
#Date: Sat Aug 29 2020 00:00:37 GMT+0200 (Central European Summer Time)
#
# navigate mobile transmitter
#OBJ:
# - merge BOOL (def: false): Add "Merge: COMMIT COMMIT2"