faker 5.0.0 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. package/Readme.md +4 -0
  2. package/dist/faker.js +4980 -1829
  3. package/dist/faker.min.js +1 -1
  4. package/lib/address.js +20 -1
  5. package/lib/finance.js +17 -1
  6. package/lib/helpers.js +10 -3
  7. package/lib/image.js +3 -0
  8. package/lib/image_providers/lorempicsum.js +108 -0
  9. package/lib/index.js +1 -1
  10. package/lib/locales/en/address/country_code.js +0 -1
  11. package/lib/locales/en/address/country_code_alpha_3.js +252 -0
  12. package/lib/locales/en/address/index.js +1 -0
  13. package/lib/locales/en/finance/currency.js +3 -3
  14. package/lib/locales/en_IND/phone_number/formats.js +12 -3
  15. package/lib/locales/fi/index.js +4 -0
  16. package/lib/locales/fi/name/female_first_name.js +52 -0
  17. package/lib/locales/fi/name/first_name.js +102 -0
  18. package/lib/locales/fi/name/index.js +7 -0
  19. package/lib/locales/fi/name/last_name.js +52 -0
  20. package/lib/locales/fi/name/male_first_name.js +52 -0
  21. package/lib/locales/fi/name/name.js +6 -0
  22. package/lib/locales/fr/address/city_name.js +1 -1
  23. package/lib/locales/fr/name/female_first_name.js +453 -0
  24. package/lib/locales/fr/name/index.js +2 -1
  25. package/lib/locales/fr/name/male_first_name.js +498 -0
  26. package/lib/locales/ja/index.js +2 -1
  27. package/lib/locales/ja/lorem/index.js +4 -0
  28. package/lib/locales/ja/lorem/supplemental.js +508 -0
  29. package/lib/locales/ja/lorem/words.js +511 -0
  30. package/lib/locales/pl/name/last_name.js +8 -0
  31. package/lib/locales/pt_BR/address/city_prefix.js +0 -5
  32. package/lib/locales/pt_BR/address/city_suffix.js +0 -4
  33. package/lib/locales/pt_BR/address/postcode.js +0 -1
  34. package/lib/locales/pt_BR/address/street_suffix.js +0 -2
  35. package/lib/locales/pt_BR/commerce/color.js +47 -0
  36. package/lib/locales/pt_BR/commerce/department.js +24 -0
  37. package/lib/locales/pt_BR/commerce/index.js +5 -0
  38. package/lib/locales/pt_BR/commerce/product_name.js +59 -0
  39. package/lib/locales/pt_BR/date/index.js +4 -0
  40. package/lib/locales/pt_BR/date/month.js +63 -0
  41. package/lib/locales/pt_BR/date/weekday.js +43 -0
  42. package/lib/locales/pt_BR/index.js +2 -0
  43. package/lib/locales/pt_BR/name/first_name.js +120 -42
  44. package/lib/locales/pt_PT/phone_number/formats.js +1 -0
  45. package/lib/locales/ru/index.js +1 -0
  46. package/lib/locales/ru/lorem/index.js +3 -0
  47. package/lib/locales/ru/lorem/words.js +191 -0
  48. package/lib/locales/ru/name/index.js +6 -5
  49. package/lib/locales/ru/name/title.js +42 -0
  50. package/lib/locales/sv/commerce/product_name.js +8 -8
  51. package/lib/locales/vi/address/city_root.js +40 -40
  52. package/lib/locales/vi/address/country.js +195 -0
  53. package/lib/locales/vi/address/index.js +2 -1
  54. package/lib/locales/vi/address/postcode.js +3 -0
  55. package/lib/locales/vi/cell_phone/formats.js +5 -6
  56. package/lib/locales/vi/date/index.js +4 -0
  57. package/lib/locales/vi/date/month.js +63 -0
  58. package/lib/locales/vi/date/weekday.js +43 -0
  59. package/lib/locales/vi/index.js +1 -0
  60. package/lib/locales/vi/phone_number/formats.js +1 -14
  61. package/lib/locales/zh_CN/phone_number/formats.js +3 -3
  62. package/lib/locales.js +1 -0
  63. package/lib/lorem.js +11 -4
  64. package/lib/name.js +10 -0
  65. package/lib/random.js +2 -2
  66. package/locale/fi.js +5 -0
  67. package/package.json +1 -1
  68. package/vendor/user-agent.js +2 -1
  69. package/lib/locales/fr/name/first_name.js +0 -91
  70. package/lib/locales/vi/address/county.js +0 -73
package/lib/address.js CHANGED
@@ -195,9 +195,20 @@ function Address (faker) {
195
195
  * countryCode
196
196
  *
197
197
  * @method faker.address.countryCode
198
+ * @param {string} alphaCode default alpha-2
198
199
  */
199
- this.countryCode = function () {
200
+ this.countryCode = function (alphaCode) {
201
+
202
+ if (typeof alphaCode === 'undefined' || alphaCode === 'alpha-2') {
203
+ return faker.random.arrayElement(faker.definitions.address.country_code);
204
+ }
205
+
206
+ if (alphaCode === 'alpha-3') {
207
+ return faker.random.arrayElement(faker.definitions.address.country_code_alpha_3);
208
+ }
209
+
200
210
  return faker.random.arrayElement(faker.definitions.address.country_code);
211
+
201
212
  }
202
213
 
203
214
  /**
@@ -373,6 +384,14 @@ function Address (faker) {
373
384
  return [randomCoord[0].toFixed(4), randomCoord[1].toFixed(4)];
374
385
  }
375
386
 
387
+ /**
388
+ * Return a random time zone
389
+ * @method faker.address.timeZone
390
+ */
391
+ this.timeZone = function() {
392
+ return faker.random.arrayElement(faker.definitions.address.time_zone);
393
+ }
394
+
376
395
  return this;
377
396
  }
378
397
 
package/lib/finance.js CHANGED
@@ -224,7 +224,7 @@ self.litecoinAddress = function () {
224
224
  };
225
225
  /**
226
226
  * Credit card CVV
227
- * @method faker.finance.creditCardNumber
227
+ * @method faker.finance.creditCardCVV
228
228
  */
229
229
  self.creditCardCVV = function() {
230
230
  var cvv = "";
@@ -309,6 +309,22 @@ self.litecoinAddress = function () {
309
309
  prob < 40 ?
310
310
  Helpers.replaceSymbols("###") : "");
311
311
  };
312
+
313
+ /**
314
+ * description
315
+ *
316
+ * @method faker.finance.transactionDescription
317
+ */
318
+ self.transactionDescription = function() {
319
+ var account = Helpers.createTransaction().account
320
+ var card = faker.finance.mask();
321
+ var currency = faker.finance.currencyCode();
322
+ var amount = Helpers.createTransaction().amount
323
+ var transactionType = Helpers.createTransaction().type
324
+ var company = Helpers.createTransaction().business
325
+ return transactionType + " transaction at " + company + " using card ending with ***" + card + " for " + currency + " " + amount + " in account ***" + account
326
+ }
327
+
312
328
  };
313
329
 
314
330
  module['exports'] = Finance;
package/lib/helpers.js CHANGED
@@ -194,17 +194,24 @@ var Helpers = function (faker) {
194
194
  };
195
195
 
196
196
  /**
197
- * takes an array and returns it randomized
197
+ * takes an array and randomizes it in place then returns it
198
+ *
199
+ * uses the modern version of the Fisher–Yates algorithm
198
200
  *
199
201
  * @method faker.helpers.shuffle
200
202
  * @param {array} o
201
203
  */
202
204
  self.shuffle = function (o) {
203
205
  if (typeof o === 'undefined' || o.length === 0) {
204
- return [];
206
+ return o || [];
205
207
  }
206
208
  o = o || ["a", "b", "c"];
207
- for (var j, x, i = o.length-1; i; j = faker.random.number(i), x = o[--i], o[i] = o[j], o[j] = x);
209
+ for (var x, j, i = o.length - 1; i > 0; --i) {
210
+ j = faker.random.number(i);
211
+ x = o[i];
212
+ o[i] = o[j];
213
+ o[j] = x;
214
+ }
208
215
  return o;
209
216
  };
210
217
 
package/lib/image.js CHANGED
@@ -3,6 +3,7 @@
3
3
  * @namespace faker.image
4
4
  * @property {object} lorempixel - faker.image.lorempixel
5
5
  * @property {object} unsplash - faker.image.unsplash
6
+ * @property {object} unsplash - faker.image.lorempicsum
6
7
  * @default Default provider is unsplash image provider
7
8
  */
8
9
  var Image = function (faker) {
@@ -10,6 +11,7 @@ var Image = function (faker) {
10
11
  var self = this;
11
12
  var Lorempixel = require('./image_providers/lorempixel');
12
13
  var Unsplash = require('./image_providers/unsplash');
14
+ var LoremPicsum = require('./image_providers/lorempicsum');
13
15
 
14
16
  /**
15
17
  * image
@@ -218,6 +220,7 @@ var Image = function (faker) {
218
220
 
219
221
  self.lorempixel = new Lorempixel(faker);
220
222
  self.unsplash = new Unsplash(faker);
223
+ self.lorempicsum = new LoremPicsum(faker);
221
224
 
222
225
  // Object.assign(self, self.unsplash);
223
226
  // How to set default as unsplash? should be image.default?
@@ -0,0 +1,108 @@
1
+ /**
2
+ *
3
+ * @namespace lorempicsum
4
+ * @memberof faker.image
5
+ */
6
+ var LoremPicsum = function (faker) {
7
+
8
+ var self = this;
9
+
10
+ /**
11
+ * image
12
+ *
13
+ * @param {number} width
14
+ * @param {number} height
15
+ * @param {boolean} grayscale
16
+ * @param {number} blur 1-10
17
+ * @method faker.image.lorempicsum.image
18
+ * @description search image from unsplash
19
+ */
20
+ self.image = function (width, height, grayscale, blur) {
21
+ return self.imageUrl(width, height, grayscale, blur);
22
+ };
23
+ /**
24
+ * imageGrayscaled
25
+ *
26
+ * @param {number} width
27
+ * @param {number} height
28
+ * @param {boolean} grayscale
29
+ * @method faker.image.lorempicsum.imageGrayscaled
30
+ * @description search grayscale image from unsplash
31
+ */
32
+ self.imageGrayscale = function (width, height, grayscale) {
33
+ return self.imageUrl(width, height, grayscale);
34
+ };
35
+ /**
36
+ * imageBlurred
37
+ *
38
+ * @param {number} width
39
+ * @param {number} height
40
+ * @param {number} blur 1-10
41
+ * @method faker.image.lorempicsum.imageBlurred
42
+ * @description search blurred image from unsplash
43
+ */
44
+ self.imageBlurred = function (width, height, blur) {
45
+ return self.imageUrl(width, height, undefined, blur);
46
+ };
47
+ /**
48
+ * imageRandomSeeded
49
+ *
50
+ * @param {number} width
51
+ * @param {number} height
52
+ * @param {boolean} grayscale
53
+ * @param {number} blur 1-10
54
+ * @param {string} seed
55
+ * @method faker.image.lorempicsum.imageRandomSeeded
56
+ * @description search same random image from unsplash, based on a seed
57
+ */
58
+ self.imageRandomSeeded = function (width, height, grayscale, blur, seed) {
59
+ return self.imageUrl(width, height, grayscale, blur, seed);
60
+ };
61
+ /**
62
+ * avatar
63
+ *
64
+ * @method faker.image.lorempicsum.avatar
65
+ */
66
+ self.avatar = function () {
67
+ return faker.internet.avatar();
68
+ };
69
+ /**
70
+ * imageUrl
71
+ *
72
+ * @param {number} width
73
+ * @param {number} height
74
+ * @param {boolean} grayscale
75
+ * @param {number} blur 1-10
76
+ * @param {string} seed
77
+ * @method faker.image.lorempicsum.imageUrl
78
+ */
79
+ self.imageUrl = function (width, height, grayscale, blur, seed) {
80
+ var width = width || 640;
81
+ var height = height || 480;
82
+
83
+ var url = 'https://picsum.photos';
84
+
85
+ if (seed) {
86
+ url += '/seed/' + seed;
87
+ }
88
+
89
+ url += '/' + width + '/' + height;
90
+
91
+ if (grayscale && blur) {
92
+ return url + '?grayscale' + '&blur=' + blur;
93
+ }
94
+
95
+ if (grayscale) {
96
+ return url + '?grayscale';
97
+ }
98
+
99
+ if (blur) {
100
+ return url + '?blur=' + blur;
101
+ }
102
+
103
+ return url;
104
+ };
105
+ }
106
+
107
+ module["exports"] = LoremPicsum;
108
+
package/lib/index.js CHANGED
@@ -100,7 +100,7 @@ function Faker (opts) {
100
100
 
101
101
  var _definitions = {
102
102
  "name": ["first_name", "last_name", "prefix", "suffix", "gender", "title", "male_prefix", "female_prefix", "male_first_name", "female_first_name", "male_middle_name", "female_middle_name", "male_last_name", "female_last_name"],
103
- "address": ["city_prefix", "city_suffix", "street_suffix", "county", "country", "country_code", "state", "state_abbr", "street_prefix", "postcode", "postcode_by_state", "direction", "direction_abbr"],
103
+ "address": ["city_prefix", "city_suffix", "street_suffix", "county", "country", "country_code", "country_code_alpha_3", "state", "state_abbr", "street_prefix", "postcode", "postcode_by_state", "direction", "direction_abbr", "time_zone"],
104
104
  "company": ["adjective", "noun", "descriptor", "bs_adjective", "bs_noun", "bs_verb", "suffix"],
105
105
  "lorem": ["words"],
106
106
  "hacker": ["abbreviation", "adjective", "noun", "verb", "ingverb", "phrase"],
@@ -29,7 +29,6 @@ module["exports"] = [
29
29
  "BN",
30
30
  "BO",
31
31
  "BQ",
32
- "BQ",
33
32
  "BR",
34
33
  "BS",
35
34
  "BT",
@@ -0,0 +1,252 @@
1
+ module["exports"] = [
2
+ "BGD",
3
+ "BEL",
4
+ "BFA",
5
+ "BGR",
6
+ "BIH",
7
+ "BRB",
8
+ "WLF",
9
+ "BLM",
10
+ "BMU",
11
+ "BRN",
12
+ "BOL",
13
+ "BHR",
14
+ "BDI",
15
+ "BEN",
16
+ "BTN",
17
+ "JAM",
18
+ "BVT",
19
+ "BWA",
20
+ "WSM",
21
+ "BES",
22
+ "BRA",
23
+ "BHS",
24
+ "JEY",
25
+ "BLR",
26
+ "BLZ",
27
+ "RUS",
28
+ "RWA",
29
+ "SRB",
30
+ "TLS",
31
+ "REU",
32
+ "TKM",
33
+ "TJK",
34
+ "ROU",
35
+ "TKL",
36
+ "GNB",
37
+ "GUM",
38
+ "GTM",
39
+ "SGS",
40
+ "GRC",
41
+ "GNQ",
42
+ "GLP",
43
+ "JPN",
44
+ "GUY",
45
+ "GGY",
46
+ "GUF",
47
+ "GEO",
48
+ "GRD",
49
+ "GBR",
50
+ "GAB",
51
+ "SLV",
52
+ "GIN",
53
+ "GMB",
54
+ "GRL",
55
+ "GIB",
56
+ "GHA",
57
+ "OMN",
58
+ "TUN",
59
+ "JOR",
60
+ "HRV",
61
+ "HTI",
62
+ "HUN",
63
+ "HKG",
64
+ "HND",
65
+ "HMD",
66
+ "VEN",
67
+ "PRI",
68
+ "PSE",
69
+ "PLW",
70
+ "PRT",
71
+ "SJM",
72
+ "PRY",
73
+ "IRQ",
74
+ "PAN",
75
+ "PYF",
76
+ "PNG",
77
+ "PER",
78
+ "PAK",
79
+ "PHL",
80
+ "PCN",
81
+ "POL",
82
+ "SPM",
83
+ "ZMB",
84
+ "ESH",
85
+ "EST",
86
+ "EGY",
87
+ "ZAF",
88
+ "ECU",
89
+ "ITA",
90
+ "VNM",
91
+ "SLB",
92
+ "ETH",
93
+ "SOM",
94
+ "ZWE",
95
+ "SAU",
96
+ "ESP",
97
+ "ERI",
98
+ "MNE",
99
+ "MDA",
100
+ "MDG",
101
+ "MAF",
102
+ "MAR",
103
+ "MCO",
104
+ "UZB",
105
+ "MMR",
106
+ "MLI",
107
+ "MAC",
108
+ "MNG",
109
+ "MHL",
110
+ "MKD",
111
+ "MUS",
112
+ "MLT",
113
+ "MWI",
114
+ "MDV",
115
+ "MTQ",
116
+ "MNP",
117
+ "MSR",
118
+ "MRT",
119
+ "IMN",
120
+ "UGA",
121
+ "TZA",
122
+ "MYS",
123
+ "MEX",
124
+ "ISR",
125
+ "FRA",
126
+ "IOT",
127
+ "SHN",
128
+ "FIN",
129
+ "FJI",
130
+ "FLK",
131
+ "FSM",
132
+ "FRO",
133
+ "NIC",
134
+ "NLD",
135
+ "NOR",
136
+ "NAM",
137
+ "VUT",
138
+ "NCL",
139
+ "NER",
140
+ "NFK",
141
+ "NGA",
142
+ "NZL",
143
+ "NPL",
144
+ "NRU",
145
+ "NIU",
146
+ "COK",
147
+ "XKX",
148
+ "CIV",
149
+ "CHE",
150
+ "COL",
151
+ "CHN",
152
+ "CMR",
153
+ "CHL",
154
+ "CCK",
155
+ "CAN",
156
+ "COG",
157
+ "CAF",
158
+ "COD",
159
+ "CZE",
160
+ "CYP",
161
+ "CXR",
162
+ "CRI",
163
+ "CUW",
164
+ "CPV",
165
+ "CUB",
166
+ "SWZ",
167
+ "SYR",
168
+ "SXM",
169
+ "KGZ",
170
+ "KEN",
171
+ "SSD",
172
+ "SUR",
173
+ "KIR",
174
+ "KHM",
175
+ "KNA",
176
+ "COM",
177
+ "STP",
178
+ "SVK",
179
+ "KOR",
180
+ "SVN",
181
+ "PRK",
182
+ "KWT",
183
+ "SEN",
184
+ "SMR",
185
+ "SLE",
186
+ "SYC",
187
+ "KAZ",
188
+ "CYM",
189
+ "SGP",
190
+ "SWE",
191
+ "SDN",
192
+ "DOM",
193
+ "DMA",
194
+ "DJI",
195
+ "DNK",
196
+ "VGB",
197
+ "DEU",
198
+ "YEM",
199
+ "DZA",
200
+ "USA",
201
+ "URY",
202
+ "MYT",
203
+ "UMI",
204
+ "LBN",
205
+ "LCA",
206
+ "LAO",
207
+ "TUV",
208
+ "TWN",
209
+ "TTO",
210
+ "TUR",
211
+ "LKA",
212
+ "LIE",
213
+ "LVA",
214
+ "TON",
215
+ "LTU",
216
+ "LUX",
217
+ "LBR",
218
+ "LSO",
219
+ "THA",
220
+ "ATF",
221
+ "TGO",
222
+ "TCD",
223
+ "TCA",
224
+ "LBY",
225
+ "VAT",
226
+ "VCT",
227
+ "ARE",
228
+ "AND",
229
+ "ATG",
230
+ "AFG",
231
+ "AIA",
232
+ "VIR",
233
+ "ISL",
234
+ "IRN",
235
+ "ARM",
236
+ "ALB",
237
+ "AGO",
238
+ "ATA",
239
+ "ASM",
240
+ "ARG",
241
+ "AUS",
242
+ "AUT",
243
+ "ABW",
244
+ "IND",
245
+ "ALA",
246
+ "AZE",
247
+ "IRL",
248
+ "IDN",
249
+ "UKR",
250
+ "QAT",
251
+ "MOZ"
252
+ ];
@@ -5,6 +5,7 @@ address.city_suffix = require("./city_suffix");
5
5
  address.county = require("./county");
6
6
  address.country = require("./country");
7
7
  address.country_code = require("./country_code");
8
+ address.country_code_alpha_3 = require("./country_code_alpha_3");
8
9
  address.building_number = require("./building_number");
9
10
  address.street_suffix = require("./street_suffix");
10
11
  address.secondary_address = require("./secondary_address");
@@ -512,8 +512,8 @@ module["exports"] = {
512
512
  "symbol": "$"
513
513
  },
514
514
  "Dobra": {
515
- "code": "STD",
516
- "symbol": ""
515
+ "code": "STN",
516
+ "symbol": "Db"
517
517
  },
518
518
  "El Salvador Colon": {
519
519
  "code": "SVC",
@@ -549,7 +549,7 @@ module["exports"] = {
549
549
  },
550
550
  "Turkish Lira": {
551
551
  "code": "TRY",
552
- "symbol": "TL"
552
+ "symbol": ""
553
553
  },
554
554
  "Trinidad and Tobago Dollar": {
555
555
  "code": "TTD",
@@ -1,5 +1,14 @@
1
1
  module["exports"] = [
2
- "+91###-###-####",
3
- "+91##########",
4
- "+91-###-#######"
2
+ "+919##-###-####",
3
+ "+919#########",
4
+ "+91-9##-#######",
5
+ "+918##-###-####",
6
+ "+918#########",
7
+ "+91-8##-#######",
8
+ "+917##-###-####",
9
+ "+917#########",
10
+ "+91-7##-#######",
11
+ "+916##-###-####",
12
+ "+916#########",
13
+ "+91-6##-#######",
5
14
  ];
@@ -0,0 +1,4 @@
1
+ var fi = {};
2
+ module['exports'] = fi;
3
+ fi.title = "Finnish";
4
+ fi.name = require("./name");
@@ -0,0 +1,52 @@
1
+ module["exports"] = [
2
+ "Aino",
3
+ "Anja",
4
+ "Anna",
5
+ "Anne",
6
+ "Anneli",
7
+ "Annikki",
8
+ "Eeva",
9
+ "Elina",
10
+ "Elisabet",
11
+ "Emilia",
12
+ "Eveliina",
13
+ "Hanna",
14
+ "Hannele",
15
+ "Helena",
16
+ "Inkeri",
17
+ "Irmeli",
18
+ "Johanna",
19
+ "Kaarina",
20
+ "Karoliina",
21
+ "Katariina",
22
+ "Kristiina",
23
+ "Kyllikki",
24
+ "Laura",
25
+ "Leena",
26
+ "Liisa",
27
+ "Maarit",
28
+ "Maija",
29
+ "Mari",
30
+ "Maria",
31
+ "Marika",
32
+ "Marja",
33
+ "Marjatta",
34
+ "Minna",
35
+ "Orvokki",
36
+ "Pauliina",
37
+ "Pirjo",
38
+ "Pirkko",
39
+ "Päivi",
40
+ "Riitta",
41
+ "Ritva",
42
+ "Sari",
43
+ "Satu",
44
+ "Sinikka",
45
+ "Sofia",
46
+ "Susanna",
47
+ "Tarja",
48
+ "Tellervo",
49
+ "Tiina",
50
+ "Tuula",
51
+ "Tuulikki"
52
+ ];