faker 5.3.1 → 5.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{.jshintignore → .eslintignore} +0 -0
- package/.eslintrc +54 -0
- package/.travis.yml +3 -0
- package/Readme.md +48 -3
- package/dist/faker.js +71873 -39072
- package/dist/faker.min.js +1 -1
- package/lib/address.js +121 -107
- package/lib/animal.js +124 -0
- package/lib/commerce.js +16 -16
- package/lib/company.js +8 -8
- package/lib/database.js +4 -4
- package/lib/datatype.js +226 -0
- package/lib/date.js +94 -72
- package/lib/finance.js +44 -22
- package/lib/git.js +1 -1
- package/lib/helpers.js +8 -8
- package/lib/iban.js +22 -14
- package/lib/image.js +14 -14
- package/lib/image_providers/lorempixel.js +1 -1
- package/lib/index.js +58 -47
- package/lib/internet.js +148 -119
- package/lib/locales/af_ZA/name/female_first_name.js +112 -112
- package/lib/locales/af_ZA/name/first_name.js +222 -222
- package/lib/locales/af_ZA/name/male_first_name.js +115 -115
- package/lib/locales/ar/address/state.js +62 -1
- package/lib/locales/ar/date/index.js +4 -0
- package/lib/locales/ar/date/month.js +63 -0
- package/lib/locales/ar/date/weekday.js +22 -0
- package/lib/locales/ar/index.js +2 -0
- package/lib/locales/cz/address/index.js +0 -1
- package/lib/locales/cz/name/first_name.js +3 -0
- package/lib/locales/cz/name/index.js +2 -0
- package/lib/locales/cz/name/last_name.js +3 -0
- package/lib/locales/de_CH/address/city.js +3 -0
- package/lib/locales/de_CH/address/city_name.js +102 -0
- package/lib/locales/de_CH/address/index.js +4 -0
- package/lib/locales/de_CH/address/state.js +28 -0
- package/lib/locales/de_CH/address/state_abbr.js +28 -0
- package/lib/locales/de_CH/name/first_name.js +336 -336
- package/lib/locales/de_CH/name/last_name.js +209 -209
- package/lib/locales/en/address/city_name.js +1002 -0
- package/lib/locales/en/address/country_code_alpha_3.js +250 -250
- package/lib/locales/en/address/index.js +1 -0
- package/lib/locales/en/animal/bear.js +10 -0
- package/lib/locales/en/animal/bird.js +916 -0
- package/lib/locales/en/animal/cat.js +57 -0
- package/lib/locales/en/animal/cetacean.js +56 -0
- package/lib/locales/en/animal/cow.js +521 -0
- package/lib/locales/en/animal/crocodilia.js +26 -0
- package/lib/locales/en/animal/dog.js +499 -0
- package/lib/locales/en/animal/fish.js +98 -0
- package/lib/locales/en/animal/horse.js +347 -0
- package/lib/locales/en/animal/index.js +16 -0
- package/lib/locales/en/animal/insect.js +132 -0
- package/lib/locales/en/animal/lion.js +9 -0
- package/lib/locales/en/animal/rabbit.js +51 -0
- package/lib/locales/en/animal/snake.js +583 -0
- package/lib/locales/en/animal/type.js +15 -0
- package/lib/locales/en/finance/currency.js +0 -4
- package/lib/locales/en/index.js +1 -0
- package/lib/locales/en/internet/avatar_uri.js +1250 -1254
- package/lib/locales/en/music/genre.js +18 -18
- package/lib/locales/en/name/binary_gender.js +4 -0
- package/lib/locales/en/name/female_first_name.js +501 -501
- package/lib/locales/en/name/gender.js +71 -71
- package/lib/locales/en/name/index.js +1 -0
- package/lib/locales/en/name/male_first_name.js +501 -501
- package/lib/locales/en/system/directoryPaths.js +60 -60
- package/lib/locales/en/vehicle/bicycle.js +20 -0
- package/lib/locales/en/vehicle/index.js +1 -0
- package/lib/locales/en_GH/address/building_number.js +5 -0
- package/lib/locales/en_GH/address/city.js +3 -0
- package/lib/locales/en_GH/address/city_name.js +355 -0
- package/lib/locales/en_GH/address/default_country.js +3 -0
- package/lib/locales/en_GH/address/index.js +12 -0
- package/lib/locales/en_GH/address/postcode.js +4 -0
- package/lib/locales/en_GH/address/state.js +18 -0
- package/lib/locales/en_GH/address/street_address.js +3 -0
- package/lib/locales/en_GH/address/street_name.js +4 -0
- package/lib/locales/en_GH/address/street_prefix.js +3 -0
- package/lib/locales/en_GH/address/street_suffix.js +10 -0
- package/lib/locales/en_GH/company/index.js +4 -0
- package/lib/locales/en_GH/company/name.js +4 -0
- package/lib/locales/en_GH/company/suffix.js +4 -0
- package/lib/locales/en_GH/index.js +8 -0
- package/lib/locales/en_GH/internet/domain_suffix.js +11 -0
- package/lib/locales/en_GH/internet/index.js +3 -0
- package/lib/locales/en_GH/name/female_first_name.js +146 -0
- package/lib/locales/en_GH/name/first_name.js +4 -0
- package/lib/locales/en_GH/name/index.js +7 -0
- package/lib/locales/en_GH/name/last_name.js +124 -0
- package/lib/locales/en_GH/name/male_first_name.js +134 -0
- package/lib/locales/en_GH/name/name.js +6 -0
- package/lib/locales/en_GH/phone_number/formats.js +28 -0
- package/lib/locales/{nep → en_GH}/phone_number/index.js +0 -0
- package/lib/locales/en_NG/address/city_prefix.js +525 -525
- package/lib/locales/en_NG/address/state.js +37 -37
- package/lib/locales/en_NG/name/female_first_name.js +13 -13
- package/lib/locales/en_NG/name/first_name.js +33 -33
- package/lib/locales/en_NG/name/male_first_name.js +22 -22
- package/lib/locales/en_NG/phone_number/formats.js +5 -5
- package/lib/locales/en_US/address/postcode_by_state.js +104 -104
- package/lib/locales/en_ZA/address/city_prefix.js +14 -14
- package/lib/locales/en_ZA/address/state.js +9 -9
- package/lib/locales/en_ZA/cell_phone/formats.js +18 -18
- package/lib/locales/en_ZA/name/female_first_name.js +292 -292
- package/lib/locales/en_ZA/name/first_name.js +539 -539
- package/lib/locales/en_ZA/name/male_first_name.js +252 -252
- package/lib/locales/es/commerce/color.js +9 -9
- package/lib/locales/es/commerce/department.js +19 -19
- package/lib/locales/es/commerce/product_name.js +54 -54
- package/lib/locales/es/name/female_first_name.js +12 -12
- package/lib/locales/es/name/male_first_name.js +17 -17
- package/lib/locales/es_MX/address/street.js +39 -39
- package/lib/locales/es_MX/commerce/color.js +31 -31
- package/lib/locales/es_MX/commerce/department.js +22 -22
- package/lib/locales/es_MX/commerce/product_name.js +56 -56
- package/lib/locales/es_MX/company/bs_noun.js +44 -44
- package/lib/locales/es_MX/company/bs_verb.js +60 -60
- package/lib/locales/es_MX/lorem/words.js +268 -268
- package/lib/locales/es_MX/name/first_name.js +304 -304
- package/lib/locales/es_MX/name/last_name.js +686 -686
- package/lib/locales/es_MX/name/title.js +1 -1
- package/lib/locales/es_MX/team/creature.js +66 -66
- package/lib/locales/fa/name/female_first_name.js +67 -67
- package/lib/locales/fa/name/male_first_name.js +74 -74
- package/lib/locales/fa/vehicle/model.js +1 -1
- package/lib/locales/fi/name/female_first_name.js +50 -50
- package/lib/locales/fi/name/first_name.js +100 -100
- package/lib/locales/fi/name/last_name.js +50 -50
- package/lib/locales/fi/name/male_first_name.js +50 -50
- package/lib/locales/fr/address/city_name.js +84 -84
- package/lib/locales/fr/address/country.js +195 -0
- package/lib/locales/fr/address/index.js +1 -0
- package/lib/locales/fr/name/female_first_name.js +451 -451
- package/lib/locales/fr/name/first_name.js +3 -0
- package/lib/locales/fr/name/index.js +1 -0
- package/lib/locales/fr/name/male_first_name.js +496 -496
- package/lib/locales/fr_BE/adresses/building_number.js +12 -0
- package/lib/locales/fr_BE/adresses/city.js +4 -0
- package/lib/locales/fr_BE/adresses/city_prefix.js +265 -0
- package/lib/locales/fr_BE/adresses/city_suffix.js +6 -0
- package/lib/locales/fr_BE/adresses/default_country.js +3 -0
- package/lib/locales/fr_BE/adresses/index.js +25 -0
- package/lib/locales/fr_BE/adresses/postcode.js +3 -0
- package/lib/locales/fr_BE/adresses/state.js +12 -0
- package/lib/locales/fr_BE/adresses/state_abbr.js +11 -0
- package/lib/locales/fr_BE/adresses/street_address.js +3 -0
- package/lib/locales/fr_BE/adresses/street_name.js +5 -0
- package/lib/locales/fr_BE/adresses/street_prefix.js +21 -0
- package/lib/locales/fr_BE/adresses/street_suffix.js +212 -0
- package/lib/locales/fr_BE/cell_phone/formats.js +34 -0
- package/lib/locales/fr_BE/cell_phone/index.js +3 -0
- package/lib/locales/fr_BE/index.js +20 -0
- package/lib/locales/fr_BE/internet/domain_suffix.js +10 -0
- package/lib/locales/fr_BE/internet/free_email.js +6 -0
- package/lib/locales/{nep → fr_BE}/internet/index.js +0 -0
- package/lib/locales/fr_BE/name/first_name.js +3009 -0
- package/lib/locales/fr_BE/name/first_name_female.js +1532 -0
- package/lib/locales/fr_BE/name/first_name_male.js +1482 -0
- package/lib/locales/fr_BE/name/gender.js +10 -0
- package/lib/locales/fr_BE/name/index.js +11 -0
- package/lib/locales/fr_BE/name/last_name.js +624 -0
- package/lib/locales/fr_BE/name/name.js +8 -0
- package/lib/locales/fr_BE/name/prefix.js +6 -0
- package/lib/locales/fr_BE/name/suffix.js +8 -0
- package/lib/locales/fr_BE/name/title.js +22 -0
- package/lib/locales/fr_BE/phone_number/formats.js +93 -0
- package/lib/locales/fr_BE/phone_number/index.js +3 -0
- package/lib/locales/hr/address/city_name.js +128 -128
- package/lib/locales/hr/address/country.js +246 -246
- package/lib/locales/hr/address/street.js +375 -375
- package/lib/locales/hr/date/month.js +24 -24
- package/lib/locales/hr/date/weekday.js +7 -7
- package/lib/locales/hr/name/female_first_name.js +238 -238
- package/lib/locales/hr/name/first_name.js +409 -409
- package/lib/locales/hr/name/last_name.js +11617 -11617
- package/lib/locales/hr/name/male_first_name.js +171 -171
- package/lib/locales/hr/name/name.js +6 -6
- package/lib/locales/hr/name/prefix.js +5 -5
- package/lib/locales/hr/name/suffix.js +2 -2
- package/lib/locales/hy/address/building_number.js +8 -0
- package/lib/locales/hy/address/city.js +4 -0
- package/lib/locales/hy/address/city_prefix.js +7 -0
- package/lib/locales/hy/address/city_suffix.js +5 -0
- package/lib/locales/hy/address/country.js +231 -0
- package/lib/locales/hy/address/default_country.js +3 -0
- package/lib/locales/hy/address/direction.js +10 -0
- package/lib/locales/hy/address/index.js +14 -0
- package/lib/locales/hy/address/secondary_address.js +4 -0
- package/lib/locales/hy/address/state.js +21 -0
- package/lib/locales/hy/address/street_address.js +3 -0
- package/lib/locales/hy/address/street_name.js +3 -0
- package/lib/locales/hy/address/street_suffix.js +4 -0
- package/lib/locales/hy/commerce/color.js +14 -0
- package/lib/locales/hy/commerce/index.js +3 -0
- package/lib/locales/hy/date/index.js +4 -0
- package/lib/locales/hy/date/month.js +30 -0
- package/lib/locales/hy/date/weekday.js +21 -0
- package/lib/locales/hy/index.js +11 -0
- package/lib/locales/hy/internet/domain_suffix.js +9 -0
- package/lib/locales/hy/internet/index.js +3 -0
- package/lib/locales/hy/lorem/index.js +3 -0
- package/lib/locales/hy/lorem/words.js +191 -0
- package/lib/locales/hy/name/female_first_name.js +48 -0
- package/lib/locales/hy/name/first_name.js +93 -0
- package/lib/locales/hy/name/index.js +7 -0
- package/lib/locales/hy/name/last_name.js +94 -0
- package/lib/locales/hy/name/male_first_name.js +47 -0
- package/lib/locales/hy/name/name.js +8 -0
- package/lib/locales/hy/phone_number/formats.js +4 -0
- package/lib/locales/hy/phone_number/index.js +3 -0
- package/lib/locales/id_ID/name/female_first_name.js +45 -1
- package/lib/locales/id_ID/name/female_last_name.js +41 -1
- package/lib/locales/id_ID/name/male_last_name.js +47 -2
- package/lib/locales/it/address/city_name.js +981 -0
- package/lib/locales/it/address/index.js +1 -0
- package/lib/locales/it/name/last_name.js +2163 -628
- package/lib/locales/ja/address/country.js +169 -0
- package/lib/locales/ja/address/index.js +1 -0
- package/lib/locales/ko/address/postcode.js +2 -1
- package/lib/locales/ko/name/first_name.js +2994 -1
- package/lib/locales/ko/name/last_name.js +98 -1
- package/lib/locales/lv/commerce/product_name.js +14 -14
- package/lib/locales/nb_NO/name/index.js +2 -2
- package/lib/locales/{nep → ne}/address/city.js +0 -0
- package/lib/locales/{nep → ne}/address/default_country.js +0 -0
- package/lib/locales/{nep → ne}/address/index.js +0 -0
- package/lib/locales/{nep → ne}/address/postcode.js +0 -0
- package/lib/locales/{nep → ne}/address/state.js +0 -0
- package/lib/locales/{nep → ne}/company/index.js +0 -0
- package/lib/locales/{nep → ne}/company/suffix.js +0 -0
- package/lib/locales/ne/index.js +8 -0
- package/lib/locales/{nep → ne}/internet/domain_suffix.js +0 -0
- package/lib/locales/{nep → ne}/internet/free_email.js +0 -0
- package/lib/locales/ne/internet/index.js +4 -0
- package/lib/locales/{nep → ne}/name/first_name.js +0 -0
- package/lib/locales/{nep → ne}/name/index.js +0 -0
- package/lib/locales/{nep → ne}/name/last_name.js +0 -0
- package/lib/locales/{nep → ne}/phone_number/formats.js +0 -0
- package/lib/locales/ne/phone_number/index.js +3 -0
- package/lib/locales/nl/address/country.js +5 -7
- package/lib/locales/nl/address/secondary_address.js +2 -1
- package/lib/locales/nl/address/street_suffix.js +3 -1
- package/lib/locales/nl/commerce/color.js +38 -0
- package/lib/locales/nl/commerce/department.js +24 -0
- package/lib/locales/nl/commerce/index.js +5 -0
- package/lib/locales/nl/commerce/product_name.js +72 -0
- package/lib/locales/nl/company/suffix.js +5 -2
- package/lib/locales/nl/date/index.js +4 -0
- package/lib/locales/nl/date/month.js +63 -0
- package/lib/locales/nl/date/weekday.js +43 -0
- package/lib/locales/nl/hacker/adjective.js +25 -0
- package/lib/locales/nl/hacker/index.js +6 -0
- package/lib/locales/nl/hacker/noun.js +28 -0
- package/lib/locales/nl/hacker/phrase.js +10 -0
- package/lib/locales/nl/hacker/verb.js +23 -0
- package/lib/locales/nl/index.js +3 -0
- package/lib/locales/nl/internet/domain_suffix.js +2 -1
- package/lib/locales/nl/name/female_first_name.js +517 -0
- package/lib/locales/nl/name/index.js +2 -0
- package/lib/locales/nl/name/male_first_name.js +590 -0
- package/lib/locales/pl/name/female_first_name.js +176 -0
- package/lib/locales/pl/name/first_name.js +3 -410
- package/lib/locales/pl/name/male_first_name.js +236 -0
- package/lib/locales/pt_BR/address/city_suffix.js +4 -0
- package/lib/locales/pt_BR/address/country.js +41 -44
- package/lib/locales/pt_BR/address/state_abbr.js +4 -1
- package/lib/locales/pt_BR/company/suffix.js +1 -0
- package/lib/locales/pt_BR/name/female_first_name.js +82 -0
- package/lib/locales/pt_BR/name/index.js +2 -0
- package/lib/locales/pt_BR/name/male_first_name.js +90 -0
- package/lib/locales/pt_BR/name/name.js +8 -0
- package/lib/locales/pt_BR/name/prefix.js +2 -1
- package/lib/locales/pt_PT/phone_number/formats.js +1 -0
- package/lib/locales/ro/address/city.js +300 -300
- package/lib/locales/ro/address/county.js +42 -42
- package/lib/locales/ro/address/state.js +42 -42
- package/lib/locales/ro/address/state_abbr.js +42 -42
- package/lib/locales/ro/address/street_address.js +1 -1
- package/lib/locales/ro/address/street_suffix.js +3 -3
- package/lib/locales/ro/address/streets.js +100 -100
- package/lib/locales/ro/cell_phone/formats.js +59 -59
- package/lib/locales/ro/internet/domain_suffix.js +19 -19
- package/lib/locales/ro/internet/index.js +0 -1
- package/lib/locales/ro/name/female_first_name.js +387 -387
- package/lib/locales/ro/name/last_name.js +300 -300
- package/lib/locales/ro/name/male_first_name.js +288 -288
- package/lib/locales/ro/name/name.js +32 -32
- package/lib/locales/ro/name/prefix.js +3 -3
- package/lib/locales/ro/name/suffix.js +2 -2
- package/lib/locales/ro/phone_number/formats.js +82 -82
- package/lib/locales/sk/address/index.js +0 -1
- package/lib/locales/tr/name/female_first_name.js +416 -0
- package/lib/locales/tr/name/index.js +2 -0
- package/lib/locales/tr/name/male_first_name.js +754 -0
- package/lib/locales/tr/name/name.js +2 -2
- package/lib/locales/vi/name/female_first_name.js +1312 -0
- package/lib/locales/vi/name/first_name.js +3 -28
- package/lib/locales/vi/name/index.js +5 -3
- package/lib/locales/vi/name/last_name.js +1 -48
- package/lib/locales/vi/name/male_first_name.js +1227 -0
- package/lib/locales/vi/name/name.js +3 -2
- package/lib/locales/zu_ZA/name/female_first_name.js +50 -50
- package/lib/locales/zu_ZA/name/first_name.js +100 -100
- package/lib/locales/zu_ZA/name/last_name.js +100 -100
- package/lib/locales/zu_ZA/name/male_first_name.js +51 -51
- package/lib/locales.js +2 -1
- package/lib/lorem.js +25 -25
- package/lib/mersenne.js +31 -0
- package/lib/music.js +9 -9
- package/lib/name.js +36 -32
- package/lib/phone_number.js +4 -4
- package/lib/random.js +138 -150
- package/lib/system.js +114 -63
- package/lib/time.js +1 -1
- package/lib/vehicle.js +38 -4
- package/locale/ReadMe.md +1 -1
- package/locale/en.js +1 -1
- package/locale/en_GH.js +5 -0
- package/locale/hy.js +5 -0
- package/locale/ne.js +5 -0
- package/package.json +4 -3
- package/vendor/mersenne.js +194 -222
- package/vendor/user-agent.js +155 -155
- package/.jshintrc +0 -87
- package/lib/locales/cz/address/time_zone.js +0 -145
- package/lib/locales/el/internet/avatar_uri.js +0 -1256
- package/lib/locales/nep/index.js +0 -8
- package/lib/locales/ro/internet/avatar_uri.js +0 -1265
- package/lib/locales/sk/address/time_zone.js +0 -145
- package/locale/nep.js +0 -5
package/lib/iban.js
CHANGED
|
@@ -9,16 +9,16 @@ module["exports"] = {
|
|
|
9
9
|
"001", "002", "003", "004", "005", "006", "007", "008", "009"
|
|
10
10
|
],
|
|
11
11
|
toDigitString: function (str) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
return str.replace(/[A-Z]/gi, function(match) {
|
|
13
|
+
return match.toUpperCase().charCodeAt(0) - 55;
|
|
14
|
+
});
|
|
15
15
|
},
|
|
16
16
|
mod97: function (digitStr) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
var m = 0;
|
|
18
|
+
for (var i = 0; i < digitStr.length; i++) {
|
|
19
|
+
m = ((m * 10) + (digitStr[i] |0)) % 97;
|
|
20
|
+
}
|
|
21
|
+
return m;
|
|
22
22
|
},
|
|
23
23
|
formats: [
|
|
24
24
|
{
|
|
@@ -67,11 +67,19 @@ module["exports"] = {
|
|
|
67
67
|
format: "ATkk bbbb bccc cccc cccc"
|
|
68
68
|
},
|
|
69
69
|
{
|
|
70
|
+
// Azerbaijan
|
|
71
|
+
// https://transferwise.com/fr/iban/azerbaijan
|
|
72
|
+
// Length 28
|
|
73
|
+
// BBAN 2c,16n
|
|
74
|
+
// GEkk bbbb cccc cccc cccc cccc cccc
|
|
75
|
+
// b = National bank code (alpha)
|
|
76
|
+
// c = Account number
|
|
77
|
+
// example IBAN AZ21 NABZ 0000 0000 1370 1000 1944
|
|
70
78
|
country: "AZ",
|
|
71
79
|
total: 28,
|
|
72
80
|
bban: [
|
|
73
81
|
{
|
|
74
|
-
type: "
|
|
82
|
+
type: "a",
|
|
75
83
|
count: 4
|
|
76
84
|
},
|
|
77
85
|
{
|
|
@@ -342,7 +350,7 @@ module["exports"] = {
|
|
|
342
350
|
total: 22,
|
|
343
351
|
bban: [
|
|
344
352
|
{
|
|
345
|
-
type: "
|
|
353
|
+
type: "a",
|
|
346
354
|
count: 2
|
|
347
355
|
},
|
|
348
356
|
{
|
|
@@ -813,7 +821,7 @@ module["exports"] = {
|
|
|
813
821
|
total: 24,
|
|
814
822
|
bban: [
|
|
815
823
|
{
|
|
816
|
-
type: "
|
|
824
|
+
type: "a",
|
|
817
825
|
count: 4
|
|
818
826
|
},
|
|
819
827
|
{
|
|
@@ -1050,11 +1058,11 @@ module["exports"] = {
|
|
|
1050
1058
|
count: 5
|
|
1051
1059
|
},
|
|
1052
1060
|
{
|
|
1053
|
-
type: "
|
|
1061
|
+
type: "n",
|
|
1054
1062
|
count: 1
|
|
1055
1063
|
},
|
|
1056
1064
|
{
|
|
1057
|
-
type: "
|
|
1065
|
+
type: "n",
|
|
1058
1066
|
count: 16
|
|
1059
1067
|
}
|
|
1060
1068
|
],
|
|
@@ -1133,4 +1141,4 @@ module["exports"] = {
|
|
|
1133
1141
|
"UM", "US", "UY", "UZ", "VA", "VC", "VE", "VG", "VI", "VN", "VU", "WF", "WS",
|
|
1134
1142
|
"YE", "YT", "YU", "ZA", "ZM", "ZR", "ZW"
|
|
1135
1143
|
]
|
|
1136
|
-
}
|
|
1144
|
+
}
|
package/lib/image.js
CHANGED
|
@@ -43,22 +43,22 @@ var Image = function (faker) {
|
|
|
43
43
|
* @method faker.image.imageUrl
|
|
44
44
|
*/
|
|
45
45
|
self.imageUrl = function (width, height, category, randomize, https) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
46
|
+
var width = width || 640;
|
|
47
|
+
var height = height || 480;
|
|
48
|
+
var protocol = 'http://';
|
|
49
|
+
if (typeof https !== 'undefined' && https === true) {
|
|
50
|
+
protocol = 'https://';
|
|
51
|
+
}
|
|
52
|
+
var url = protocol + 'placeimg.com/' + width + '/' + height;
|
|
53
|
+
if (typeof category !== 'undefined') {
|
|
54
|
+
url += '/' + category;
|
|
55
|
+
}
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
if (randomize) {
|
|
58
|
+
url += '?' + faker.datatype.number()
|
|
59
|
+
}
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
return url;
|
|
62
62
|
};
|
|
63
63
|
/**
|
|
64
64
|
* abstract
|
package/lib/index.js
CHANGED
|
@@ -38,12 +38,63 @@ function Faker (opts) {
|
|
|
38
38
|
|
|
39
39
|
self.definitions = {};
|
|
40
40
|
|
|
41
|
+
var _definitions = {
|
|
42
|
+
"name": ["first_name", "last_name", "prefix", "suffix", "binary_gender", "gender", "title", "male_prefix", "female_prefix", "male_first_name", "female_first_name", "male_middle_name", "female_middle_name", "male_last_name", "female_last_name"],
|
|
43
|
+
"address": ["city_name", "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"],
|
|
44
|
+
"animal": ["dog", "cat", "snake", "bear", "lion", "cetacean", "insect", "crocodilia", "cow", "bird", "fish", "rabbit", "horse", "type"],
|
|
45
|
+
"company": ["adjective", "noun", "descriptor", "bs_adjective", "bs_noun", "bs_verb", "suffix"],
|
|
46
|
+
"lorem": ["words"],
|
|
47
|
+
"hacker": ["abbreviation", "adjective", "noun", "verb", "ingverb", "phrase"],
|
|
48
|
+
"phone_number": ["formats"],
|
|
49
|
+
"finance": ["account_type", "transaction_type", "currency", "iban", "credit_card"],
|
|
50
|
+
"internet": ["avatar_uri", "domain_suffix", "free_email", "example_email", "password"],
|
|
51
|
+
"commerce": ["color", "department", "product_name", "price", "categories", "product_description"],
|
|
52
|
+
"database": ["collation", "column", "engine", "type"],
|
|
53
|
+
"system": ["mimeTypes", "directoryPaths"],
|
|
54
|
+
"date": ["month", "weekday"],
|
|
55
|
+
"vehicle": ["vehicle", "manufacturer", "model", "type", "fuel", "vin", "color"],
|
|
56
|
+
"music": ["genre"],
|
|
57
|
+
"title": "",
|
|
58
|
+
"separator": ""
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// Create a Getter for all definitions.foo.bar properties
|
|
62
|
+
Object.keys(_definitions).forEach(function(d){
|
|
63
|
+
if (typeof self.definitions[d] === "undefined") {
|
|
64
|
+
self.definitions[d] = {};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (typeof _definitions[d] === "string") {
|
|
68
|
+
self.definitions[d] = _definitions[d];
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
_definitions[d].forEach(function(p){
|
|
73
|
+
Object.defineProperty(self.definitions[d], p, {
|
|
74
|
+
get: function () {
|
|
75
|
+
if (typeof self.locales[self.locale][d] === "undefined" || typeof self.locales[self.locale][d][p] === "undefined") {
|
|
76
|
+
// certain localization sets contain less data then others.
|
|
77
|
+
// in the case of a missing definition, use the default localeFallback to substitute the missing set data
|
|
78
|
+
// throw new Error('unknown property ' + d + p)
|
|
79
|
+
return self.locales[localeFallback][d][p];
|
|
80
|
+
} else {
|
|
81
|
+
// return localized data
|
|
82
|
+
return self.locales[self.locale][d][p];
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
41
89
|
var Fake = require('./fake');
|
|
42
90
|
self.fake = new Fake(self).fake;
|
|
43
91
|
|
|
44
92
|
var Unique = require('./unique');
|
|
45
93
|
self.unique = new Unique(self).unique;
|
|
46
94
|
|
|
95
|
+
var Mersenne = require('./mersenne');
|
|
96
|
+
self.mersenne = new Mersenne();
|
|
97
|
+
|
|
47
98
|
var Random = require('./random');
|
|
48
99
|
self.random = new Random(self);
|
|
49
100
|
|
|
@@ -56,6 +107,9 @@ function Faker (opts) {
|
|
|
56
107
|
var Address = require('./address');
|
|
57
108
|
self.address = new Address(self);
|
|
58
109
|
|
|
110
|
+
var Animal = require('./animal');
|
|
111
|
+
self.animal = new Animal(self);
|
|
112
|
+
|
|
59
113
|
var Company = require('./company');
|
|
60
114
|
self.company = new Company(self);
|
|
61
115
|
|
|
@@ -101,53 +155,8 @@ function Faker (opts) {
|
|
|
101
155
|
var Music = require('./music');
|
|
102
156
|
self.music = new Music(self);
|
|
103
157
|
|
|
104
|
-
var
|
|
105
|
-
|
|
106
|
-
"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"],
|
|
107
|
-
"company": ["adjective", "noun", "descriptor", "bs_adjective", "bs_noun", "bs_verb", "suffix"],
|
|
108
|
-
"lorem": ["words"],
|
|
109
|
-
"hacker": ["abbreviation", "adjective", "noun", "verb", "ingverb", "phrase"],
|
|
110
|
-
"phone_number": ["formats"],
|
|
111
|
-
"finance": ["account_type", "transaction_type", "currency", "iban", "credit_card"],
|
|
112
|
-
"internet": ["avatar_uri", "domain_suffix", "free_email", "example_email", "password"],
|
|
113
|
-
"commerce": ["color", "department", "product_name", "price", "categories", "product_description"],
|
|
114
|
-
"database": ["collation", "column", "engine", "type"],
|
|
115
|
-
"system": ["mimeTypes", "directoryPaths"],
|
|
116
|
-
"date": ["month", "weekday"],
|
|
117
|
-
"vehicle": ["vehicle", "manufacturer", "model", "type", "fuel", "vin", "color"],
|
|
118
|
-
"music": ["genre"],
|
|
119
|
-
"title": "",
|
|
120
|
-
"separator": ""
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
// Create a Getter for all definitions.foo.bar properties
|
|
124
|
-
Object.keys(_definitions).forEach(function(d){
|
|
125
|
-
if (typeof self.definitions[d] === "undefined") {
|
|
126
|
-
self.definitions[d] = {};
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
if (typeof _definitions[d] === "string") {
|
|
130
|
-
self.definitions[d] = _definitions[d];
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
_definitions[d].forEach(function(p){
|
|
135
|
-
Object.defineProperty(self.definitions[d], p, {
|
|
136
|
-
get: function () {
|
|
137
|
-
if (typeof self.locales[self.locale][d] === "undefined" || typeof self.locales[self.locale][d][p] === "undefined") {
|
|
138
|
-
// certain localization sets contain less data then others.
|
|
139
|
-
// in the case of a missing definition, use the default localeFallback to substitute the missing set data
|
|
140
|
-
// throw new Error('unknown property ' + d + p)
|
|
141
|
-
return self.locales[localeFallback][d][p];
|
|
142
|
-
} else {
|
|
143
|
-
// return localized data
|
|
144
|
-
return self.locales[self.locale][d][p];
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
});
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
|
|
158
|
+
var Datatype = require('./datatype');
|
|
159
|
+
self.datatype = new Datatype(self);
|
|
151
160
|
};
|
|
152
161
|
|
|
153
162
|
Faker.prototype.setLocale = function (locale) {
|
|
@@ -156,7 +165,9 @@ Faker.prototype.setLocale = function (locale) {
|
|
|
156
165
|
|
|
157
166
|
Faker.prototype.seed = function(value) {
|
|
158
167
|
var Random = require('./random');
|
|
168
|
+
var Datatype = require('./datatype');
|
|
159
169
|
this.seedValue = value;
|
|
160
170
|
this.random = new Random(this, this.seedValue);
|
|
171
|
+
this.datatype = new Datatype(this, this.seedValue);
|
|
161
172
|
}
|
|
162
173
|
module['exports'] = Faker;
|
package/lib/internet.js
CHANGED
|
@@ -12,12 +12,12 @@ var Internet = function (faker) {
|
|
|
12
12
|
* @method faker.internet.avatar
|
|
13
13
|
*/
|
|
14
14
|
self.avatar = function () {
|
|
15
|
-
|
|
15
|
+
return 'https://cdn.fakercloud.com/avatars/' + faker.random.arrayElement(faker.definitions.internet.avatar_uri);
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
self.avatar.schema = {
|
|
19
19
|
"description": "Generates a URL for an avatar.",
|
|
20
|
-
"sampleResults": ["https://
|
|
20
|
+
"sampleResults": ["https://cdn.fakercloud.com/avatars/sydlawrence_128.jpg"]
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
/**
|
|
@@ -29,8 +29,8 @@ var Internet = function (faker) {
|
|
|
29
29
|
* @param {string} provider
|
|
30
30
|
*/
|
|
31
31
|
self.email = function (firstName, lastName, provider) {
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
provider = provider || faker.random.arrayElement(faker.definitions.internet.free_email);
|
|
33
|
+
return faker.helpers.slugify(faker.internet.userName(firstName, lastName)) + "@" + provider;
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
self.email.schema = {
|
|
@@ -62,8 +62,8 @@ var Internet = function (faker) {
|
|
|
62
62
|
* @param {string} lastName
|
|
63
63
|
*/
|
|
64
64
|
self.exampleEmail = function (firstName, lastName) {
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
var provider = faker.random.arrayElement(faker.definitions.internet.example_email);
|
|
66
|
+
return self.email(firstName, lastName, provider);
|
|
67
67
|
};
|
|
68
68
|
|
|
69
69
|
/**
|
|
@@ -74,23 +74,23 @@ var Internet = function (faker) {
|
|
|
74
74
|
* @param {string} lastName
|
|
75
75
|
*/
|
|
76
76
|
self.userName = function (firstName, lastName) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
var result;
|
|
78
|
+
firstName = firstName || faker.name.firstName();
|
|
79
|
+
lastName = lastName || faker.name.lastName();
|
|
80
|
+
switch (faker.datatype.number(2)) {
|
|
81
81
|
case 0:
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
result = firstName + faker.datatype.number(99);
|
|
83
|
+
break;
|
|
84
84
|
case 1:
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
result = firstName + faker.random.arrayElement([".", "_"]) + lastName;
|
|
86
|
+
break;
|
|
87
87
|
case 2:
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
88
|
+
result = firstName + faker.random.arrayElement([".", "_"]) + lastName + faker.datatype.number(99);
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
result = result.toString().replace(/'/g, "");
|
|
92
|
+
result = result.replace(/ /g, "");
|
|
93
|
+
return result;
|
|
94
94
|
};
|
|
95
95
|
|
|
96
96
|
self.userName.schema = {
|
|
@@ -122,8 +122,8 @@ var Internet = function (faker) {
|
|
|
122
122
|
* @method faker.internet.protocol
|
|
123
123
|
*/
|
|
124
124
|
self.protocol = function () {
|
|
125
|
-
|
|
126
|
-
|
|
125
|
+
var protocols = ['http','https'];
|
|
126
|
+
return faker.random.arrayElement(protocols);
|
|
127
127
|
};
|
|
128
128
|
|
|
129
129
|
self.protocol.schema = {
|
|
@@ -131,13 +131,28 @@ var Internet = function (faker) {
|
|
|
131
131
|
"sampleResults": ["https", "http"]
|
|
132
132
|
};
|
|
133
133
|
|
|
134
|
+
/**
|
|
135
|
+
* method
|
|
136
|
+
*
|
|
137
|
+
* @method faker.internet.httpMethod
|
|
138
|
+
*/
|
|
139
|
+
self.httpMethod = function () {
|
|
140
|
+
var httpMethods = ['GET','POST', 'PUT', 'DELETE', 'PATCH'];
|
|
141
|
+
return faker.random.arrayElement(httpMethods);
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
self.httpMethod.schema = {
|
|
145
|
+
"description": "Randomly generates HTTP Methods (GET, POST, PUT, DELETE, PATCH)",
|
|
146
|
+
"sampleResults": ["GET","POST", "PUT", "DELETE", "PATCH"]
|
|
147
|
+
};
|
|
148
|
+
|
|
134
149
|
/**
|
|
135
150
|
* url
|
|
136
151
|
*
|
|
137
152
|
* @method faker.internet.url
|
|
138
153
|
*/
|
|
139
154
|
self.url = function () {
|
|
140
|
-
|
|
155
|
+
return faker.internet.protocol() + '://' + faker.internet.domainName();
|
|
141
156
|
};
|
|
142
157
|
|
|
143
158
|
self.url.schema = {
|
|
@@ -154,7 +169,7 @@ var Internet = function (faker) {
|
|
|
154
169
|
* @method faker.internet.domainName
|
|
155
170
|
*/
|
|
156
171
|
self.domainName = function () {
|
|
157
|
-
|
|
172
|
+
return faker.internet.domainWord() + "." + faker.internet.domainSuffix();
|
|
158
173
|
};
|
|
159
174
|
|
|
160
175
|
self.domainName.schema = {
|
|
@@ -168,7 +183,7 @@ var Internet = function (faker) {
|
|
|
168
183
|
* @method faker.internet.domainSuffix
|
|
169
184
|
*/
|
|
170
185
|
self.domainSuffix = function () {
|
|
171
|
-
|
|
186
|
+
return faker.random.arrayElement(faker.definitions.internet.domain_suffix);
|
|
172
187
|
};
|
|
173
188
|
|
|
174
189
|
self.domainSuffix.schema = {
|
|
@@ -182,7 +197,7 @@ var Internet = function (faker) {
|
|
|
182
197
|
* @method faker.internet.domainWord
|
|
183
198
|
*/
|
|
184
199
|
self.domainWord = function () {
|
|
185
|
-
|
|
200
|
+
return faker.name.firstName().replace(/([\\~#&*{}/:<>?|\"'])/ig, '').toLowerCase();
|
|
186
201
|
};
|
|
187
202
|
|
|
188
203
|
self.domainWord.schema = {
|
|
@@ -196,16 +211,16 @@ var Internet = function (faker) {
|
|
|
196
211
|
* @method faker.internet.ip
|
|
197
212
|
*/
|
|
198
213
|
self.ip = function () {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
214
|
+
var randNum = function () {
|
|
215
|
+
return (faker.datatype.number(255)).toFixed(0);
|
|
216
|
+
};
|
|
202
217
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
218
|
+
var result = [];
|
|
219
|
+
for (var i = 0; i < 4; i++) {
|
|
220
|
+
result[i] = randNum();
|
|
221
|
+
}
|
|
207
222
|
|
|
208
|
-
|
|
223
|
+
return result.join(".");
|
|
209
224
|
};
|
|
210
225
|
|
|
211
226
|
self.ip.schema = {
|
|
@@ -219,19 +234,19 @@ var Internet = function (faker) {
|
|
|
219
234
|
* @method faker.internet.ipv6
|
|
220
235
|
*/
|
|
221
236
|
self.ipv6 = function () {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
}
|
|
227
|
-
return result
|
|
228
|
-
};
|
|
229
|
-
|
|
230
|
-
var result = [];
|
|
231
|
-
for (var i = 0; i < 8; i++) {
|
|
232
|
-
result[i] = randHash();
|
|
237
|
+
var randHash = function () {
|
|
238
|
+
var result = "";
|
|
239
|
+
for (var i = 0; i < 4; i++) {
|
|
240
|
+
result += (faker.random.arrayElement(["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"]));
|
|
233
241
|
}
|
|
234
|
-
return result
|
|
242
|
+
return result
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
var result = [];
|
|
246
|
+
for (var i = 0; i < 8; i++) {
|
|
247
|
+
result[i] = randHash();
|
|
248
|
+
}
|
|
249
|
+
return result.join(":");
|
|
235
250
|
};
|
|
236
251
|
|
|
237
252
|
self.ipv6.schema = {
|
|
@@ -239,6 +254,20 @@ var Internet = function (faker) {
|
|
|
239
254
|
"sampleResults": ["2001:0db8:6276:b1a7:5213:22f1:25df:c8a0"]
|
|
240
255
|
};
|
|
241
256
|
|
|
257
|
+
/**
|
|
258
|
+
* port
|
|
259
|
+
*
|
|
260
|
+
* @method faker.internet.port
|
|
261
|
+
*/
|
|
262
|
+
self.port = function() {
|
|
263
|
+
return faker.datatype.number({ min: 0, max: 65535 });
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
self.port.schema = {
|
|
267
|
+
"description": "Generates a random port number.",
|
|
268
|
+
"sampleResults": ["4422"]
|
|
269
|
+
};
|
|
270
|
+
|
|
242
271
|
/**
|
|
243
272
|
* userAgent
|
|
244
273
|
*
|
|
@@ -262,17 +291,17 @@ var Internet = function (faker) {
|
|
|
262
291
|
* @param {number} baseBlue255
|
|
263
292
|
*/
|
|
264
293
|
self.color = function (baseRed255, baseGreen255, baseBlue255) {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
294
|
+
baseRed255 = baseRed255 || 0;
|
|
295
|
+
baseGreen255 = baseGreen255 || 0;
|
|
296
|
+
baseBlue255 = baseBlue255 || 0;
|
|
297
|
+
// based on awesome response : http://stackoverflow.com/questions/43044/algorithm-to-randomly-generate-an-aesthetically-pleasing-color-palette
|
|
298
|
+
var red = Math.floor((faker.datatype.number(256) + baseRed255) / 2);
|
|
299
|
+
var green = Math.floor((faker.datatype.number(256) + baseGreen255) / 2);
|
|
300
|
+
var blue = Math.floor((faker.datatype.number(256) + baseBlue255) / 2);
|
|
301
|
+
var redStr = red.toString(16);
|
|
302
|
+
var greenStr = green.toString(16);
|
|
303
|
+
var blueStr = blue.toString(16);
|
|
304
|
+
return '#' +
|
|
276
305
|
(redStr.length === 1 ? '0' : '') + redStr +
|
|
277
306
|
(greenStr.length === 1 ? '0' : '') + greenStr +
|
|
278
307
|
(blueStr.length === 1 ? '0': '') + blueStr;
|
|
@@ -308,23 +337,23 @@ var Internet = function (faker) {
|
|
|
308
337
|
* @param {string} sep
|
|
309
338
|
*/
|
|
310
339
|
self.mac = function(sep){
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
}
|
|
340
|
+
var i,
|
|
341
|
+
mac = "",
|
|
342
|
+
validSep = ':';
|
|
343
|
+
|
|
344
|
+
// if the client passed in a different separator than `:`,
|
|
345
|
+
// we will use it if it is in the list of acceptable separators (dash or no separator)
|
|
346
|
+
if (['-', ''].indexOf(sep) !== -1) {
|
|
347
|
+
validSep = sep;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
for (i=0; i < 12; i++) {
|
|
351
|
+
mac+= faker.datatype.number(15).toString(16);
|
|
352
|
+
if (i%2==1 && i != 11) {
|
|
353
|
+
mac+=validSep;
|
|
326
354
|
}
|
|
327
|
-
|
|
355
|
+
}
|
|
356
|
+
return mac;
|
|
328
357
|
};
|
|
329
358
|
|
|
330
359
|
self.mac.schema = {
|
|
@@ -341,56 +370,56 @@ var Internet = function (faker) {
|
|
|
341
370
|
* @param {string} pattern
|
|
342
371
|
* @param {string} prefix
|
|
343
372
|
*/
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
373
|
+
self.password = function (len, memorable, pattern, prefix) {
|
|
374
|
+
len = len || 15;
|
|
375
|
+
if (typeof memorable === "undefined") {
|
|
376
|
+
memorable = false;
|
|
377
|
+
}
|
|
378
|
+
/*
|
|
350
379
|
* password-generator ( function )
|
|
351
380
|
* Copyright(c) 2011-2013 Bermi Ferrer <bermi@bermilabs.com>
|
|
352
381
|
* MIT Licensed
|
|
353
382
|
*/
|
|
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
|
-
|
|
383
|
+
var consonant, letter, vowel;
|
|
384
|
+
letter = /[a-zA-Z]$/;
|
|
385
|
+
vowel = /[aeiouAEIOU]$/;
|
|
386
|
+
consonant = /[bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ]$/;
|
|
387
|
+
var _password = function (length, memorable, pattern, prefix) {
|
|
388
|
+
var char, n;
|
|
389
|
+
if (length == null) {
|
|
390
|
+
length = 10;
|
|
391
|
+
}
|
|
392
|
+
if (memorable == null) {
|
|
393
|
+
memorable = true;
|
|
394
|
+
}
|
|
395
|
+
if (pattern == null) {
|
|
396
|
+
pattern = /\w/;
|
|
397
|
+
}
|
|
398
|
+
if (prefix == null) {
|
|
399
|
+
prefix = '';
|
|
400
|
+
}
|
|
401
|
+
if (prefix.length >= length) {
|
|
402
|
+
return prefix;
|
|
403
|
+
}
|
|
404
|
+
if (memorable) {
|
|
405
|
+
if (prefix.match(consonant)) {
|
|
406
|
+
pattern = vowel;
|
|
407
|
+
} else {
|
|
408
|
+
pattern = consonant;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
n = faker.datatype.number(94) + 33;
|
|
412
|
+
char = String.fromCharCode(n);
|
|
413
|
+
if (memorable) {
|
|
414
|
+
char = char.toLowerCase();
|
|
415
|
+
}
|
|
416
|
+
if (!char.match(pattern)) {
|
|
417
|
+
return _password(length, memorable, pattern, prefix);
|
|
418
|
+
}
|
|
419
|
+
return _password(length, memorable, pattern, "" + prefix + char);
|
|
420
|
+
};
|
|
421
|
+
return _password(len, memorable, pattern, prefix);
|
|
422
|
+
}
|
|
394
423
|
|
|
395
424
|
self.password.schema = {
|
|
396
425
|
"description": "Generates a random password.",
|