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/vendor/mersenne.js
CHANGED
|
@@ -52,235 +52,207 @@
|
|
|
52
52
|
|
|
53
53
|
function MersenneTwister19937()
|
|
54
54
|
{
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
55
|
+
/* constants should be scoped inside the class */
|
|
56
|
+
var N, M, MATRIX_A, UPPER_MASK, LOWER_MASK;
|
|
57
|
+
/* Period parameters */
|
|
58
|
+
//c//#define N 624
|
|
59
|
+
//c//#define M 397
|
|
60
|
+
//c//#define MATRIX_A 0x9908b0dfUL /* constant vector a */
|
|
61
|
+
//c//#define UPPER_MASK 0x80000000UL /* most significant w-r bits */
|
|
62
|
+
//c//#define LOWER_MASK 0x7fffffffUL /* least significant r bits */
|
|
63
|
+
N = 624;
|
|
64
|
+
M = 397;
|
|
65
|
+
MATRIX_A = 0x9908b0df; /* constant vector a */
|
|
66
|
+
UPPER_MASK = 0x80000000; /* most significant w-r bits */
|
|
67
|
+
LOWER_MASK = 0x7fffffff; /* least significant r bits */
|
|
68
|
+
//c//static unsigned long mt[N]; /* the array for the state vector */
|
|
69
|
+
//c//static int mti=N+1; /* mti==N+1 means mt[N] is not initialized */
|
|
70
|
+
var mt = new Array(N); /* the array for the state vector */
|
|
71
|
+
var mti = N+1; /* mti==N+1 means mt[N] is not initialized */
|
|
72
|
+
|
|
73
|
+
function unsigned32 (n1) // returns a 32-bits unsiged integer from an operand to which applied a bit operator.
|
|
74
|
+
{
|
|
75
|
+
return n1 < 0 ? (n1 ^ UPPER_MASK) + UPPER_MASK : n1;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function subtraction32 (n1, n2) // emulates lowerflow of a c 32-bits unsiged integer variable, instead of the operator -. these both arguments must be non-negative integers expressible using unsigned 32 bits.
|
|
79
|
+
{
|
|
80
|
+
return n1 < n2 ? unsigned32((0x100000000 - (n2 - n1)) & 0xffffffff) : n1 - n2;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function addition32 (n1, n2) // emulates overflow of a c 32-bits unsiged integer variable, instead of the operator +. these both arguments must be non-negative integers expressible using unsigned 32 bits.
|
|
84
|
+
{
|
|
85
|
+
return unsigned32((n1 + n2) & 0xffffffff)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function multiplication32 (n1, n2) // emulates overflow of a c 32-bits unsiged integer variable, instead of the operator *. these both arguments must be non-negative integers expressible using unsigned 32 bits.
|
|
89
|
+
{
|
|
90
|
+
var sum = 0;
|
|
91
|
+
for (var i = 0; i < 32; ++i){
|
|
92
|
+
if ((n1 >>> i) & 0x1){
|
|
93
|
+
sum = addition32(sum, unsigned32(n2 << i));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return sum;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/* initializes mt[N] with a seed */
|
|
100
|
+
//c//void init_genrand(unsigned long s)
|
|
101
|
+
this.init_genrand = function (s)
|
|
102
|
+
{
|
|
103
|
+
//c//mt[0]= s & 0xffffffff;
|
|
104
|
+
mt[0]= unsigned32(s & 0xffffffff);
|
|
105
|
+
for (mti=1; mti<N; mti++) {
|
|
106
|
+
mt[mti] =
|
|
107
107
|
//c//(1812433253 * (mt[mti-1] ^ (mt[mti-1] >> 30)) + mti);
|
|
108
108
|
addition32(multiplication32(1812433253, unsigned32(mt[mti-1] ^ (mt[mti-1] >>> 30))), mti);
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
109
|
+
/* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */
|
|
110
|
+
/* In the previous versions, MSBs of the seed affect */
|
|
111
|
+
/* only MSBs of the array mt[]. */
|
|
112
|
+
/* 2002/01/09 modified by Makoto Matsumoto */
|
|
113
|
+
//c//mt[mti] &= 0xffffffff;
|
|
114
|
+
mt[mti] = unsigned32(mt[mti] & 0xffffffff);
|
|
115
|
+
/* for >32 bit machines */
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/* initialize by an array with array-length */
|
|
120
|
+
/* init_key is the array for initializing keys */
|
|
121
|
+
/* key_length is its length */
|
|
122
|
+
/* slight change for C++, 2004/2/26 */
|
|
123
|
+
//c//void init_by_array(unsigned long init_key[], int key_length)
|
|
124
|
+
this.init_by_array = function (init_key, key_length)
|
|
125
|
+
{
|
|
126
|
+
//c//int i, j, k;
|
|
127
|
+
var i, j, k;
|
|
128
|
+
//c//init_genrand(19650218);
|
|
129
|
+
this.init_genrand(19650218);
|
|
130
|
+
i=1; j=0;
|
|
131
|
+
k = (N>key_length ? N : key_length);
|
|
132
|
+
for (; k; k--) {
|
|
133
|
+
//c//mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1664525))
|
|
134
|
+
//c// + init_key[j] + j; /* non linear */
|
|
135
|
+
mt[i] = addition32(addition32(unsigned32(mt[i] ^ multiplication32(unsigned32(mt[i-1] ^ (mt[i-1] >>> 30)), 1664525)), init_key[j]), j);
|
|
136
|
+
mt[i] =
|
|
137
137
|
//c//mt[i] &= 0xffffffff; /* for WORDSIZE > 32 machines */
|
|
138
138
|
unsigned32(mt[i] & 0xffffffff);
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
139
|
+
i++; j++;
|
|
140
|
+
if (i>=N) { mt[0] = mt[N-1]; i=1; }
|
|
141
|
+
if (j>=key_length) {j=0;}
|
|
142
|
+
}
|
|
143
|
+
for (k=N-1; k; k--) {
|
|
144
|
+
//c//mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1566083941))
|
|
145
|
+
//c//- i; /* non linear */
|
|
146
|
+
mt[i] = subtraction32(unsigned32((dbg=mt[i]) ^ multiplication32(unsigned32(mt[i-1] ^ (mt[i-1] >>> 30)), 1566083941)), i);
|
|
147
|
+
//c//mt[i] &= 0xffffffff; /* for WORDSIZE > 32 machines */
|
|
148
|
+
mt[i] = unsigned32(mt[i] & 0xffffffff);
|
|
149
|
+
i++;
|
|
150
|
+
if (i>=N) { mt[0] = mt[N-1]; i=1; }
|
|
151
|
+
}
|
|
152
|
+
mt[0] = 0x80000000; /* MSB is 1; assuring non-zero initial array */
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/* moved outside of genrand_int32() by jwatte 2010-11-17; generate less garbage */
|
|
156
|
+
var mag01 = [0x0, MATRIX_A];
|
|
157
|
+
|
|
158
|
+
/* generates a random number on [0,0xffffffff]-interval */
|
|
159
|
+
//c//unsigned long genrand_int32(void)
|
|
160
|
+
this.genrand_int32 = function ()
|
|
161
|
+
{
|
|
162
|
+
//c//unsigned long y;
|
|
163
|
+
//c//static unsigned long mag01[2]={0x0UL, MATRIX_A};
|
|
164
|
+
var y;
|
|
165
|
+
/* mag01[x] = x * MATRIX_A for x=0,1 */
|
|
166
|
+
|
|
167
|
+
if (mti >= N) { /* generate N words at one time */
|
|
168
|
+
//c//int kk;
|
|
169
|
+
var kk;
|
|
170
|
+
|
|
171
|
+
if (mti == N+1) /* if init_genrand() has not been called, */
|
|
172
|
+
//c//init_genrand(5489); /* a default initial seed is used */
|
|
173
|
+
{this.init_genrand(5489);} /* a default initial seed is used */
|
|
174
|
+
|
|
175
|
+
for (kk=0;kk<N-M;kk++) {
|
|
176
|
+
//c//y = (mt[kk]&UPPER_MASK)|(mt[kk+1]&LOWER_MASK);
|
|
177
|
+
//c//mt[kk] = mt[kk+M] ^ (y >> 1) ^ mag01[y & 0x1];
|
|
178
|
+
y = unsigned32((mt[kk]&UPPER_MASK)|(mt[kk+1]&LOWER_MASK));
|
|
179
|
+
mt[kk] = unsigned32(mt[kk+M] ^ (y >>> 1) ^ mag01[y & 0x1]);
|
|
180
|
+
}
|
|
181
|
+
for (;kk<N-1;kk++) {
|
|
182
|
+
//c//y = (mt[kk]&UPPER_MASK)|(mt[kk+1]&LOWER_MASK);
|
|
183
|
+
//c//mt[kk] = mt[kk+(M-N)] ^ (y >> 1) ^ mag01[y & 0x1];
|
|
184
|
+
y = unsigned32((mt[kk]&UPPER_MASK)|(mt[kk+1]&LOWER_MASK));
|
|
185
|
+
mt[kk] = unsigned32(mt[kk+(M-N)] ^ (y >>> 1) ^ mag01[y & 0x1]);
|
|
186
|
+
}
|
|
187
|
+
//c//y = (mt[N-1]&UPPER_MASK)|(mt[0]&LOWER_MASK);
|
|
188
|
+
//c//mt[N-1] = mt[M-1] ^ (y >> 1) ^ mag01[y & 0x1];
|
|
189
|
+
y = unsigned32((mt[N-1]&UPPER_MASK)|(mt[0]&LOWER_MASK));
|
|
190
|
+
mt[N-1] = unsigned32(mt[M-1] ^ (y >>> 1) ^ mag01[y & 0x1]);
|
|
191
|
+
mti = 0;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
y = mt[mti++];
|
|
195
|
+
|
|
196
|
+
/* Tempering */
|
|
197
|
+
//c//y ^= (y >> 11);
|
|
198
|
+
//c//y ^= (y << 7) & 0x9d2c5680;
|
|
199
|
+
//c//y ^= (y << 15) & 0xefc60000;
|
|
200
|
+
//c//y ^= (y >> 18);
|
|
201
|
+
y = unsigned32(y ^ (y >>> 11));
|
|
202
|
+
y = unsigned32(y ^ ((y << 7) & 0x9d2c5680));
|
|
203
|
+
y = unsigned32(y ^ ((y << 15) & 0xefc60000));
|
|
204
|
+
y = unsigned32(y ^ (y >>> 18));
|
|
205
|
+
|
|
206
|
+
return y;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/* generates a random number on [0,0x7fffffff]-interval */
|
|
210
|
+
//c//long genrand_int31(void)
|
|
211
|
+
this.genrand_int31 = function ()
|
|
212
|
+
{
|
|
213
|
+
//c//return (genrand_int32()>>1);
|
|
214
|
+
return (this.genrand_int32()>>>1);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/* generates a random number on [0,1]-real-interval */
|
|
218
|
+
//c//double genrand_real1(void)
|
|
219
|
+
this.genrand_real1 = function ()
|
|
220
|
+
{
|
|
221
|
+
//c//return genrand_int32()*(1.0/4294967295.0);
|
|
222
|
+
return this.genrand_int32()*(1.0/4294967295.0);
|
|
223
|
+
/* divided by 2^32-1 */
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/* generates a random number on [0,1)-real-interval */
|
|
227
|
+
//c//double genrand_real2(void)
|
|
228
|
+
this.genrand_real2 = function ()
|
|
229
|
+
{
|
|
230
|
+
//c//return genrand_int32()*(1.0/4294967296.0);
|
|
231
|
+
return this.genrand_int32()*(1.0/4294967296.0);
|
|
232
|
+
/* divided by 2^32 */
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/* generates a random number on (0,1)-real-interval */
|
|
236
|
+
//c//double genrand_real3(void)
|
|
237
|
+
this.genrand_real3 = function ()
|
|
238
|
+
{
|
|
239
|
+
//c//return ((genrand_int32()) + 0.5)*(1.0/4294967296.0);
|
|
240
|
+
return ((this.genrand_int32()) + 0.5)*(1.0/4294967296.0);
|
|
241
|
+
/* divided by 2^32 */
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/* generates a random number on [0,1) with 53-bit resolution*/
|
|
245
|
+
//c//double genrand_res53(void)
|
|
246
|
+
this.genrand_res53 = function ()
|
|
247
|
+
{
|
|
248
|
+
//c//unsigned long a=genrand_int32()>>5, b=genrand_int32()>>6;
|
|
249
|
+
var a=this.genrand_int32()>>>5, b=this.genrand_int32()>>>6;
|
|
250
|
+
return(a*67108864.0+b)*(1.0/9007199254740992.0);
|
|
251
|
+
}
|
|
252
|
+
/* These real versions are due to Isaku Wada, 2002/01/09 added */
|
|
253
253
|
}
|
|
254
254
|
|
|
255
255
|
// Exports: Public API
|
|
256
256
|
|
|
257
257
|
// Export the twister class
|
|
258
258
|
exports.MersenneTwister19937 = MersenneTwister19937;
|
|
259
|
-
|
|
260
|
-
// Export a simplified function to generate random numbers
|
|
261
|
-
var gen = new MersenneTwister19937;
|
|
262
|
-
gen.init_genrand((new Date).getTime() % 1000000000);
|
|
263
|
-
|
|
264
|
-
// Added max, min range functionality, Marak Squires Sept 11 2014
|
|
265
|
-
exports.rand = function(max, min) {
|
|
266
|
-
if (max === undefined)
|
|
267
|
-
{
|
|
268
|
-
min = 0;
|
|
269
|
-
max = 32768;
|
|
270
|
-
}
|
|
271
|
-
return Math.floor(gen.genrand_real2() * (max - min) + min);
|
|
272
|
-
}
|
|
273
|
-
exports.seed = function(S) {
|
|
274
|
-
if (typeof(S) != 'number')
|
|
275
|
-
{
|
|
276
|
-
throw new Error("seed(S) must take numeric argument; is " + typeof(S));
|
|
277
|
-
}
|
|
278
|
-
gen.init_genrand(S);
|
|
279
|
-
}
|
|
280
|
-
exports.seed_array = function(A) {
|
|
281
|
-
if (typeof(A) != 'object')
|
|
282
|
-
{
|
|
283
|
-
throw new Error("seed_array(A) must take array of numbers; is " + typeof(A));
|
|
284
|
-
}
|
|
285
|
-
gen.init_by_array(A, A.length);
|
|
286
|
-
}
|