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/datatype.js
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @namespace faker.datatype
|
|
4
|
+
*/
|
|
5
|
+
function Datatype (faker, seed) {
|
|
6
|
+
// Use a user provided seed if it is an array or number
|
|
7
|
+
if (Array.isArray(seed) && seed.length) {
|
|
8
|
+
faker.mersenne.seed_array(seed);
|
|
9
|
+
}
|
|
10
|
+
else if(!isNaN(seed)) {
|
|
11
|
+
faker.mersenne.seed(seed);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* returns a single random number based on a max number or range
|
|
16
|
+
*
|
|
17
|
+
* @method faker.datatype.number
|
|
18
|
+
* @param {mixed} options {min, max, precision}
|
|
19
|
+
*/
|
|
20
|
+
this.number = function (options) {
|
|
21
|
+
|
|
22
|
+
if (typeof options === "number") {
|
|
23
|
+
options = {
|
|
24
|
+
max: options
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
options = options || {};
|
|
29
|
+
|
|
30
|
+
if (typeof options.min === "undefined") {
|
|
31
|
+
options.min = 0;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (typeof options.max === "undefined") {
|
|
35
|
+
options.max = 99999;
|
|
36
|
+
}
|
|
37
|
+
if (typeof options.precision === "undefined") {
|
|
38
|
+
options.precision = 1;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Make the range inclusive of the max value
|
|
42
|
+
var max = options.max;
|
|
43
|
+
if (max >= 0) {
|
|
44
|
+
max += options.precision;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
var randomNumber = Math.floor(
|
|
48
|
+
faker.mersenne.rand(max / options.precision, options.min / options.precision));
|
|
49
|
+
// Workaround problem in Float point arithmetics for e.g. 6681493 / 0.01
|
|
50
|
+
randomNumber = randomNumber / (1 / options.precision);
|
|
51
|
+
|
|
52
|
+
return randomNumber;
|
|
53
|
+
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* returns a single random floating-point number based on a max number or range
|
|
58
|
+
*
|
|
59
|
+
* @method faker.datatype.float
|
|
60
|
+
* @param {mixed} options
|
|
61
|
+
*/
|
|
62
|
+
this.float = function (options) {
|
|
63
|
+
if (typeof options === "number") {
|
|
64
|
+
options = {
|
|
65
|
+
precision: options
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
options = options || {};
|
|
69
|
+
var opts = {};
|
|
70
|
+
for (var p in options) {
|
|
71
|
+
opts[p] = options[p];
|
|
72
|
+
}
|
|
73
|
+
if (typeof opts.precision === 'undefined') {
|
|
74
|
+
opts.precision = 0.01;
|
|
75
|
+
}
|
|
76
|
+
return faker.datatype.number(opts);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* method returns a Date object using a random number of milliseconds since 1. Jan 1970 UTC
|
|
81
|
+
* Caveat: seeding is not working
|
|
82
|
+
*
|
|
83
|
+
* @method faker.datatype.datetime
|
|
84
|
+
* @param {mixed} options, pass min OR max as number of milliseconds since 1. Jan 1970 UTC
|
|
85
|
+
*/
|
|
86
|
+
this.datetime = function (options) {
|
|
87
|
+
if (typeof options === "number") {
|
|
88
|
+
options = {
|
|
89
|
+
max: options
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
var minMax = 8640000000000000;
|
|
94
|
+
|
|
95
|
+
options = options || {};
|
|
96
|
+
|
|
97
|
+
if (typeof options.min === "undefined" || options.min < minMax*-1) {
|
|
98
|
+
options.min = new Date().setFullYear(1990, 1, 1);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (typeof options.max === "undefined" || options.max > minMax) {
|
|
102
|
+
options.max = new Date().setFullYear(2100,1,1);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
var random = faker.datatype.number(options);
|
|
106
|
+
return new Date(random);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Returns a string, containing UTF-16 chars between 33 and 125 ('!' to '}')
|
|
111
|
+
*
|
|
112
|
+
*
|
|
113
|
+
* @method faker.datatype.string
|
|
114
|
+
* @param { number } length: length of generated string, default = 10, max length = 2^20
|
|
115
|
+
*/
|
|
116
|
+
this.string = function (length) {
|
|
117
|
+
if(length === undefined ){
|
|
118
|
+
length = 10;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
var maxLength = Math.pow(2, 20);
|
|
122
|
+
if(length >= (maxLength)){
|
|
123
|
+
length = maxLength;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
var charCodeOption = {
|
|
127
|
+
min: 33,
|
|
128
|
+
max: 125
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
var returnString = '';
|
|
132
|
+
|
|
133
|
+
for(var i = 0; i < length; i++){
|
|
134
|
+
returnString += String.fromCharCode(faker.datatype.number(charCodeOption));
|
|
135
|
+
}
|
|
136
|
+
return returnString;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* uuid
|
|
141
|
+
*
|
|
142
|
+
* @method faker.datatype.uuid
|
|
143
|
+
*/
|
|
144
|
+
this.uuid = function () {
|
|
145
|
+
var RFC4122_TEMPLATE = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx';
|
|
146
|
+
var replacePlaceholders = function (placeholder) {
|
|
147
|
+
var random = faker.datatype.number({ min: 0, max: 15 });
|
|
148
|
+
var value = placeholder == 'x' ? random : (random &0x3 | 0x8);
|
|
149
|
+
return value.toString(16);
|
|
150
|
+
};
|
|
151
|
+
return RFC4122_TEMPLATE.replace(/[xy]/g, replacePlaceholders);
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* boolean
|
|
156
|
+
*
|
|
157
|
+
* @method faker.datatype.boolean
|
|
158
|
+
*/
|
|
159
|
+
this.boolean = function () {
|
|
160
|
+
return !!faker.datatype.number(1);
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* hexaDecimal
|
|
166
|
+
*
|
|
167
|
+
* @method faker.datatype.hexaDecimal
|
|
168
|
+
* @param {number} count defaults to 1
|
|
169
|
+
*/
|
|
170
|
+
this.hexaDecimal = function hexaDecimal(count) {
|
|
171
|
+
if (typeof count === "undefined") {
|
|
172
|
+
count = 1;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
var wholeString = "";
|
|
176
|
+
for(var i = 0; i < count; i++) {
|
|
177
|
+
wholeString += faker.random.arrayElement(["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "A", "B", "C", "D", "E", "F"]);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return "0x"+wholeString;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* returns json object with 7 pre-defined properties
|
|
185
|
+
*
|
|
186
|
+
* @method faker.datatype.json
|
|
187
|
+
*/
|
|
188
|
+
this.json = function json() {
|
|
189
|
+
|
|
190
|
+
var properties = ['foo', 'bar', 'bike', 'a', 'b', 'name', 'prop'];
|
|
191
|
+
|
|
192
|
+
var returnObject = {};
|
|
193
|
+
properties.forEach(function(prop){
|
|
194
|
+
returnObject[prop] = faker.datatype.boolean() ?
|
|
195
|
+
faker.datatype.string() : faker.datatype.number();
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
return JSON.stringify(returnObject);
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* returns an array with values generated by faker.datatype.number and faker.datatype.string
|
|
203
|
+
*
|
|
204
|
+
* @method faker.datatype.array
|
|
205
|
+
* @param { number } length of the returned array
|
|
206
|
+
*/
|
|
207
|
+
|
|
208
|
+
this.array = function array(length) {
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
if(length === undefined){
|
|
212
|
+
length = 10;
|
|
213
|
+
}
|
|
214
|
+
var returnArray = new Array(length);
|
|
215
|
+
for(var i = 0; i < length; i++){
|
|
216
|
+
returnArray[i] = faker.datatype.boolean() ?
|
|
217
|
+
faker.datatype.string() : faker.datatype.number();
|
|
218
|
+
}
|
|
219
|
+
return returnArray;
|
|
220
|
+
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
return this;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
module['exports'] = Datatype;
|
package/lib/date.js
CHANGED
|
@@ -12,21 +12,21 @@ var _Date = function (faker) {
|
|
|
12
12
|
* @param {date} refDate
|
|
13
13
|
*/
|
|
14
14
|
self.past = function (years, refDate) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
var date = new Date();
|
|
16
|
+
if (typeof refDate !== "undefined") {
|
|
17
|
+
date = new Date(Date.parse(refDate));
|
|
18
|
+
}
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
var range = {
|
|
21
|
+
min: 1000,
|
|
22
|
+
max: (years || 1) * 365 * 24 * 3600 * 1000
|
|
23
|
+
};
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
var past = date.getTime();
|
|
26
|
+
past -= faker.datatype.number(range); // some time from now to N years ago, in milliseconds
|
|
27
|
+
date.setTime(past);
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
return date;
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
/**
|
|
@@ -37,21 +37,21 @@ var _Date = function (faker) {
|
|
|
37
37
|
* @param {date} refDate
|
|
38
38
|
*/
|
|
39
39
|
self.future = function (years, refDate) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
var date = new Date();
|
|
41
|
+
if (typeof refDate !== "undefined") {
|
|
42
|
+
date = new Date(Date.parse(refDate));
|
|
43
|
+
}
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
var range = {
|
|
46
|
+
min: 1000,
|
|
47
|
+
max: (years || 1) * 365 * 24 * 3600 * 1000
|
|
48
|
+
};
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
var future = date.getTime();
|
|
51
|
+
future += faker.datatype.number(range); // some time from now to N years later, in milliseconds
|
|
52
|
+
date.setTime(future);
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
return date;
|
|
55
55
|
};
|
|
56
56
|
|
|
57
57
|
/**
|
|
@@ -62,14 +62,36 @@ var _Date = function (faker) {
|
|
|
62
62
|
* @param {date} to
|
|
63
63
|
*/
|
|
64
64
|
self.between = function (from, to) {
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
var fromMilli = Date.parse(from);
|
|
66
|
+
var dateOffset = faker.datatype.number(Date.parse(to) - fromMilli);
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
var newDate = new Date(fromMilli + dateOffset);
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
return newDate;
|
|
71
71
|
};
|
|
72
72
|
|
|
73
|
+
/**
|
|
74
|
+
* betweens
|
|
75
|
+
*
|
|
76
|
+
* @method faker.date.between
|
|
77
|
+
* @param {date} from
|
|
78
|
+
* @param {date} to
|
|
79
|
+
*/
|
|
80
|
+
self.betweens = function (from, to, num) {
|
|
81
|
+
if (typeof num == 'undefined') { num = 3; }
|
|
82
|
+
var newDates = [];
|
|
83
|
+
var fromMilli = Date.parse(from);
|
|
84
|
+
var dateOffset = (Date.parse(to) - fromMilli) / ( num + 1 );
|
|
85
|
+
var lastDate = from
|
|
86
|
+
for (var i = 0; i < num; i++) {
|
|
87
|
+
fromMilli = Date.parse(lastDate);
|
|
88
|
+
lastDate = new Date(fromMilli + dateOffset)
|
|
89
|
+
newDates.push(lastDate)
|
|
90
|
+
}
|
|
91
|
+
return newDates;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
|
|
73
95
|
/**
|
|
74
96
|
* recent
|
|
75
97
|
*
|
|
@@ -78,21 +100,21 @@ var _Date = function (faker) {
|
|
|
78
100
|
* @param {date} refDate
|
|
79
101
|
*/
|
|
80
102
|
self.recent = function (days, refDate) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
103
|
+
var date = new Date();
|
|
104
|
+
if (typeof refDate !== "undefined") {
|
|
105
|
+
date = new Date(Date.parse(refDate));
|
|
106
|
+
}
|
|
85
107
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
108
|
+
var range = {
|
|
109
|
+
min: 1000,
|
|
110
|
+
max: (days || 1) * 24 * 3600 * 1000
|
|
111
|
+
};
|
|
90
112
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
113
|
+
var future = date.getTime();
|
|
114
|
+
future -= faker.datatype.number(range); // some time from now to N days ago, in milliseconds
|
|
115
|
+
date.setTime(future);
|
|
94
116
|
|
|
95
|
-
|
|
117
|
+
return date;
|
|
96
118
|
};
|
|
97
119
|
|
|
98
120
|
/**
|
|
@@ -103,21 +125,21 @@ var _Date = function (faker) {
|
|
|
103
125
|
* @param {date} refDate
|
|
104
126
|
*/
|
|
105
127
|
self.soon = function (days, refDate) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
128
|
+
var date = new Date();
|
|
129
|
+
if (typeof refDate !== "undefined") {
|
|
130
|
+
date = new Date(Date.parse(refDate));
|
|
131
|
+
}
|
|
110
132
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
133
|
+
var range = {
|
|
134
|
+
min: 1000,
|
|
135
|
+
max: (days || 1) * 24 * 3600 * 1000
|
|
136
|
+
};
|
|
115
137
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
138
|
+
var future = date.getTime();
|
|
139
|
+
future += faker.datatype.number(range); // some time from now to N days later, in milliseconds
|
|
140
|
+
date.setTime(future);
|
|
119
141
|
|
|
120
|
-
|
|
142
|
+
return date;
|
|
121
143
|
};
|
|
122
144
|
|
|
123
145
|
/**
|
|
@@ -127,19 +149,19 @@ var _Date = function (faker) {
|
|
|
127
149
|
* @param {object} options
|
|
128
150
|
*/
|
|
129
151
|
self.month = function (options) {
|
|
130
|
-
|
|
152
|
+
options = options || {};
|
|
131
153
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
154
|
+
var type = 'wide';
|
|
155
|
+
if (options.abbr) {
|
|
156
|
+
type = 'abbr';
|
|
157
|
+
}
|
|
158
|
+
if (options.context && typeof faker.definitions.date.month[type + '_context'] !== 'undefined') {
|
|
159
|
+
type += '_context';
|
|
160
|
+
}
|
|
139
161
|
|
|
140
|
-
|
|
162
|
+
var source = faker.definitions.date.month[type];
|
|
141
163
|
|
|
142
|
-
|
|
164
|
+
return faker.random.arrayElement(source);
|
|
143
165
|
};
|
|
144
166
|
|
|
145
167
|
/**
|
|
@@ -149,19 +171,19 @@ var _Date = function (faker) {
|
|
|
149
171
|
* @method faker.date.weekday
|
|
150
172
|
*/
|
|
151
173
|
self.weekday = function (options) {
|
|
152
|
-
|
|
174
|
+
options = options || {};
|
|
153
175
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
176
|
+
var type = 'wide';
|
|
177
|
+
if (options.abbr) {
|
|
178
|
+
type = 'abbr';
|
|
179
|
+
}
|
|
180
|
+
if (options.context && typeof faker.definitions.date.weekday[type + '_context'] !== 'undefined') {
|
|
181
|
+
type += '_context';
|
|
182
|
+
}
|
|
161
183
|
|
|
162
|
-
|
|
184
|
+
var source = faker.definitions.date.weekday[type];
|
|
163
185
|
|
|
164
|
-
|
|
186
|
+
return faker.random.arrayElement(source);
|
|
165
187
|
};
|
|
166
188
|
|
|
167
189
|
return self;
|
package/lib/finance.js
CHANGED
|
@@ -103,16 +103,23 @@ var Finance = function (faker) {
|
|
|
103
103
|
*
|
|
104
104
|
* @return {string}
|
|
105
105
|
*/
|
|
106
|
-
self.amount = function (min, max, dec, symbol) {
|
|
106
|
+
self.amount = function (min, max, dec, symbol, autoFormat) {
|
|
107
107
|
|
|
108
108
|
min = min || 0;
|
|
109
109
|
max = max || 1000;
|
|
110
110
|
dec = dec === undefined ? 2 : dec;
|
|
111
111
|
symbol = symbol || '';
|
|
112
|
-
|
|
113
|
-
var stringNumber = symbol + randValue.toFixed(dec);
|
|
112
|
+
const randValue = faker.datatype.number({ max: max, min: min, precision: Math.pow(10, -dec) });
|
|
114
113
|
|
|
115
|
-
|
|
114
|
+
let formattedString;
|
|
115
|
+
if(autoFormat) {
|
|
116
|
+
formattedString = randValue.toLocaleString(undefined, {minimumFractionDigits: dec});
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
formattedString = randValue.toFixed(dec);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return symbol + formattedString;
|
|
116
123
|
};
|
|
117
124
|
|
|
118
125
|
/**
|
|
@@ -162,7 +169,7 @@ var Finance = function (faker) {
|
|
|
162
169
|
* @method faker.finance.bitcoinAddress
|
|
163
170
|
*/
|
|
164
171
|
self.bitcoinAddress = function () {
|
|
165
|
-
var addressLength = faker.
|
|
172
|
+
var addressLength = faker.datatype.number({ min: 25, max: 34 });
|
|
166
173
|
|
|
167
174
|
var address = faker.random.arrayElement(['1', '3']);
|
|
168
175
|
|
|
@@ -178,7 +185,7 @@ var Finance = function (faker) {
|
|
|
178
185
|
* @method faker.finance.litecoinAddress
|
|
179
186
|
*/
|
|
180
187
|
self.litecoinAddress = function () {
|
|
181
|
-
var addressLength = faker.
|
|
188
|
+
var addressLength = faker.datatype.number({ min: 26, max: 33 });
|
|
182
189
|
|
|
183
190
|
var address = faker.random.arrayElement(['L', 'M', '3']);
|
|
184
191
|
|
|
@@ -229,7 +236,7 @@ self.litecoinAddress = function () {
|
|
|
229
236
|
self.creditCardCVV = function() {
|
|
230
237
|
var cvv = "";
|
|
231
238
|
for (var i = 0; i < 3; i++) {
|
|
232
|
-
cvv += faker.
|
|
239
|
+
cvv += faker.datatype.number({max:9}).toString();
|
|
233
240
|
}
|
|
234
241
|
return cvv;
|
|
235
242
|
};
|
|
@@ -240,18 +247,32 @@ self.litecoinAddress = function () {
|
|
|
240
247
|
* @method faker.finance.ethereumAddress
|
|
241
248
|
*/
|
|
242
249
|
self.ethereumAddress = function () {
|
|
243
|
-
var address = faker.
|
|
244
|
-
|
|
250
|
+
var address = faker.datatype.hexaDecimal(40).toLowerCase();
|
|
245
251
|
return address;
|
|
246
252
|
};
|
|
247
253
|
|
|
248
254
|
/**
|
|
249
255
|
* iban
|
|
250
256
|
*
|
|
257
|
+
* @param {boolean} [formatted=false] - Return a formatted version of the generated IBAN.
|
|
258
|
+
* @param {string} [countryCode] - The country code from which you want to generate an IBAN, if none is provided a random country will be used.
|
|
259
|
+
* @throws Will throw an error if the passed country code is not supported.
|
|
260
|
+
*
|
|
251
261
|
* @method faker.finance.iban
|
|
252
262
|
*/
|
|
253
|
-
self.iban = function (formatted) {
|
|
254
|
-
var ibanFormat
|
|
263
|
+
self.iban = function (formatted, countryCode) {
|
|
264
|
+
var ibanFormat;
|
|
265
|
+
if (countryCode) {
|
|
266
|
+
var findFormat = function(currentFormat) { return currentFormat.country === countryCode; };
|
|
267
|
+
ibanFormat = ibanLib.formats.find(findFormat);
|
|
268
|
+
} else {
|
|
269
|
+
ibanFormat = faker.random.arrayElement(ibanLib.formats);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
if (!ibanFormat) {
|
|
273
|
+
throw new Error('Country code ' + countryCode + ' not supported.');
|
|
274
|
+
}
|
|
275
|
+
|
|
255
276
|
var s = "";
|
|
256
277
|
var count = 0;
|
|
257
278
|
for (var b = 0; b < ibanFormat.bban.length; b++) {
|
|
@@ -262,14 +283,14 @@ self.litecoinAddress = function () {
|
|
|
262
283
|
if (bban.type == "a") {
|
|
263
284
|
s += faker.random.arrayElement(ibanLib.alpha);
|
|
264
285
|
} else if (bban.type == "c") {
|
|
265
|
-
if (faker.
|
|
266
|
-
s += faker.
|
|
286
|
+
if (faker.datatype.number(100) < 80) {
|
|
287
|
+
s += faker.datatype.number(9);
|
|
267
288
|
} else {
|
|
268
289
|
s += faker.random.arrayElement(ibanLib.alpha);
|
|
269
290
|
}
|
|
270
291
|
} else {
|
|
271
|
-
if (c >= 3 && faker.
|
|
272
|
-
if (faker.
|
|
292
|
+
if (c >= 3 && faker.datatype.number(100) < 30) {
|
|
293
|
+
if (faker.datatype.boolean()) {
|
|
273
294
|
s += faker.random.arrayElement(ibanLib.pattern100);
|
|
274
295
|
c -= 2;
|
|
275
296
|
} else {
|
|
@@ -277,7 +298,7 @@ self.litecoinAddress = function () {
|
|
|
277
298
|
c--;
|
|
278
299
|
}
|
|
279
300
|
} else {
|
|
280
|
-
s += faker.
|
|
301
|
+
s += faker.datatype.number(9);
|
|
281
302
|
}
|
|
282
303
|
}
|
|
283
304
|
c--;
|
|
@@ -299,7 +320,7 @@ self.litecoinAddress = function () {
|
|
|
299
320
|
*/
|
|
300
321
|
self.bic = function () {
|
|
301
322
|
var vowels = ["A", "E", "I", "O", "U"];
|
|
302
|
-
var prob = faker.
|
|
323
|
+
var prob = faker.datatype.number(100);
|
|
303
324
|
return Helpers.replaceSymbols("???") +
|
|
304
325
|
faker.random.arrayElement(vowels) +
|
|
305
326
|
faker.random.arrayElement(ibanLib.iso3166) +
|
|
@@ -316,14 +337,15 @@ self.litecoinAddress = function () {
|
|
|
316
337
|
* @method faker.finance.transactionDescription
|
|
317
338
|
*/
|
|
318
339
|
self.transactionDescription = function() {
|
|
319
|
-
var
|
|
340
|
+
var transaction = Helpers.createTransaction();
|
|
341
|
+
var account = transaction.account;
|
|
342
|
+
var amount = transaction.amount;
|
|
343
|
+
var transactionType = transaction.type;
|
|
344
|
+
var company = transaction.business;
|
|
320
345
|
var card = faker.finance.mask();
|
|
321
346
|
var currency = faker.finance.currencyCode();
|
|
322
|
-
var amount = Helpers.createTransaction().amount
|
|
323
|
-
var transactionType = Helpers.createTransaction().type
|
|
324
|
-
var company = Helpers.createTransaction().business
|
|
325
347
|
return transactionType + " transaction at " + company + " using card ending with ***" + card + " for " + currency + " " + amount + " in account ***" + account
|
|
326
|
-
}
|
|
348
|
+
};
|
|
327
349
|
|
|
328
350
|
};
|
|
329
351
|
|
package/lib/git.js
CHANGED
|
@@ -30,7 +30,7 @@ var Git = function(faker) {
|
|
|
30
30
|
|
|
31
31
|
var entry = 'commit {{git.commitSha}}\r\n';
|
|
32
32
|
|
|
33
|
-
if (options.merge || (faker.
|
|
33
|
+
if (options.merge || (faker.datatype.number({ min: 0, max: 4 }) === 0)) {
|
|
34
34
|
entry += 'Merge: {{git.shortSha}} {{git.shortSha}}\r\n';
|
|
35
35
|
}
|
|
36
36
|
|
package/lib/helpers.js
CHANGED
|
@@ -25,7 +25,7 @@ var Helpers = function (faker) {
|
|
|
25
25
|
*/
|
|
26
26
|
self.slugify = function (string) {
|
|
27
27
|
string = string || "";
|
|
28
|
-
return string.replace(/ /g, '-').replace(/[
|
|
28
|
+
return string.replace(/ /g, '-').replace(/[^\一-龠\ぁ-ゔ\ァ-ヴー\w\.\-]+/g, '');
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
/**
|
|
@@ -45,9 +45,9 @@ var Helpers = function (faker) {
|
|
|
45
45
|
var str = '';
|
|
46
46
|
for (var i = 0; i < string.length; i++) {
|
|
47
47
|
if (string.charAt(i) == symbol) {
|
|
48
|
-
str += faker.
|
|
48
|
+
str += faker.datatype.number(9);
|
|
49
49
|
} else if (string.charAt(i) == "!"){
|
|
50
|
-
str += faker.
|
|
50
|
+
str += faker.datatype.number({min: 2, max: 9});
|
|
51
51
|
} else {
|
|
52
52
|
str += string.charAt(i);
|
|
53
53
|
}
|
|
@@ -69,11 +69,11 @@ var Helpers = function (faker) {
|
|
|
69
69
|
|
|
70
70
|
for (var i = 0; i < string.length; i++) {
|
|
71
71
|
if (string.charAt(i) == "#") {
|
|
72
|
-
str += faker.
|
|
72
|
+
str += faker.datatype.number(9);
|
|
73
73
|
} else if (string.charAt(i) == "?") {
|
|
74
74
|
str += faker.random.arrayElement(alpha);
|
|
75
75
|
} else if (string.charAt(i) == "*") {
|
|
76
|
-
str += faker.
|
|
76
|
+
str += faker.datatype.boolean() ? faker.random.arrayElement(alpha) : faker.datatype.number(9);
|
|
77
77
|
} else {
|
|
78
78
|
str += string.charAt(i);
|
|
79
79
|
}
|
|
@@ -161,7 +161,7 @@ var Helpers = function (faker) {
|
|
|
161
161
|
max = min;
|
|
162
162
|
min = tmp;
|
|
163
163
|
}
|
|
164
|
-
repetitions = faker.
|
|
164
|
+
repetitions = faker.datatype.number({min:min,max:max});
|
|
165
165
|
string = string.slice(0,token.index) + faker.helpers.repeatString(token[1], repetitions) + string.slice(token.index+token[0].length);
|
|
166
166
|
token = string.match(RANGE_REP_REG);
|
|
167
167
|
}
|
|
@@ -186,7 +186,7 @@ var Helpers = function (faker) {
|
|
|
186
186
|
min = tmp;
|
|
187
187
|
}
|
|
188
188
|
string = string.slice(0,token.index) +
|
|
189
|
-
faker.
|
|
189
|
+
faker.datatype.number({min:min, max:max}).toString() +
|
|
190
190
|
string.slice(token.index+token[0].length);
|
|
191
191
|
token = string.match(RANGE_REG);
|
|
192
192
|
}
|
|
@@ -207,7 +207,7 @@ var Helpers = function (faker) {
|
|
|
207
207
|
}
|
|
208
208
|
o = o || ["a", "b", "c"];
|
|
209
209
|
for (var x, j, i = o.length - 1; i > 0; --i) {
|
|
210
|
-
j = faker.
|
|
210
|
+
j = faker.datatype.number(i);
|
|
211
211
|
x = o[i];
|
|
212
212
|
o[i] = o[j];
|
|
213
213
|
o[j] = x;
|