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.
Files changed (332) hide show
  1. package/{.jshintignore → .eslintignore} +0 -0
  2. package/.eslintrc +54 -0
  3. package/.travis.yml +3 -0
  4. package/Readme.md +48 -3
  5. package/dist/faker.js +71873 -39072
  6. package/dist/faker.min.js +1 -1
  7. package/lib/address.js +121 -107
  8. package/lib/animal.js +124 -0
  9. package/lib/commerce.js +16 -16
  10. package/lib/company.js +8 -8
  11. package/lib/database.js +4 -4
  12. package/lib/datatype.js +226 -0
  13. package/lib/date.js +94 -72
  14. package/lib/finance.js +44 -22
  15. package/lib/git.js +1 -1
  16. package/lib/helpers.js +8 -8
  17. package/lib/iban.js +22 -14
  18. package/lib/image.js +14 -14
  19. package/lib/image_providers/lorempixel.js +1 -1
  20. package/lib/index.js +58 -47
  21. package/lib/internet.js +148 -119
  22. package/lib/locales/af_ZA/name/female_first_name.js +112 -112
  23. package/lib/locales/af_ZA/name/first_name.js +222 -222
  24. package/lib/locales/af_ZA/name/male_first_name.js +115 -115
  25. package/lib/locales/ar/address/state.js +62 -1
  26. package/lib/locales/ar/date/index.js +4 -0
  27. package/lib/locales/ar/date/month.js +63 -0
  28. package/lib/locales/ar/date/weekday.js +22 -0
  29. package/lib/locales/ar/index.js +2 -0
  30. package/lib/locales/cz/address/index.js +0 -1
  31. package/lib/locales/cz/name/first_name.js +3 -0
  32. package/lib/locales/cz/name/index.js +2 -0
  33. package/lib/locales/cz/name/last_name.js +3 -0
  34. package/lib/locales/de_CH/address/city.js +3 -0
  35. package/lib/locales/de_CH/address/city_name.js +102 -0
  36. package/lib/locales/de_CH/address/index.js +4 -0
  37. package/lib/locales/de_CH/address/state.js +28 -0
  38. package/lib/locales/de_CH/address/state_abbr.js +28 -0
  39. package/lib/locales/de_CH/name/first_name.js +336 -336
  40. package/lib/locales/de_CH/name/last_name.js +209 -209
  41. package/lib/locales/en/address/city_name.js +1002 -0
  42. package/lib/locales/en/address/country_code_alpha_3.js +250 -250
  43. package/lib/locales/en/address/index.js +1 -0
  44. package/lib/locales/en/animal/bear.js +10 -0
  45. package/lib/locales/en/animal/bird.js +916 -0
  46. package/lib/locales/en/animal/cat.js +57 -0
  47. package/lib/locales/en/animal/cetacean.js +56 -0
  48. package/lib/locales/en/animal/cow.js +521 -0
  49. package/lib/locales/en/animal/crocodilia.js +26 -0
  50. package/lib/locales/en/animal/dog.js +499 -0
  51. package/lib/locales/en/animal/fish.js +98 -0
  52. package/lib/locales/en/animal/horse.js +347 -0
  53. package/lib/locales/en/animal/index.js +16 -0
  54. package/lib/locales/en/animal/insect.js +132 -0
  55. package/lib/locales/en/animal/lion.js +9 -0
  56. package/lib/locales/en/animal/rabbit.js +51 -0
  57. package/lib/locales/en/animal/snake.js +583 -0
  58. package/lib/locales/en/animal/type.js +15 -0
  59. package/lib/locales/en/finance/currency.js +0 -4
  60. package/lib/locales/en/index.js +1 -0
  61. package/lib/locales/en/internet/avatar_uri.js +1250 -1254
  62. package/lib/locales/en/music/genre.js +18 -18
  63. package/lib/locales/en/name/binary_gender.js +4 -0
  64. package/lib/locales/en/name/female_first_name.js +501 -501
  65. package/lib/locales/en/name/gender.js +71 -71
  66. package/lib/locales/en/name/index.js +1 -0
  67. package/lib/locales/en/name/male_first_name.js +501 -501
  68. package/lib/locales/en/system/directoryPaths.js +60 -60
  69. package/lib/locales/en/vehicle/bicycle.js +20 -0
  70. package/lib/locales/en/vehicle/index.js +1 -0
  71. package/lib/locales/en_GH/address/building_number.js +5 -0
  72. package/lib/locales/en_GH/address/city.js +3 -0
  73. package/lib/locales/en_GH/address/city_name.js +355 -0
  74. package/lib/locales/en_GH/address/default_country.js +3 -0
  75. package/lib/locales/en_GH/address/index.js +12 -0
  76. package/lib/locales/en_GH/address/postcode.js +4 -0
  77. package/lib/locales/en_GH/address/state.js +18 -0
  78. package/lib/locales/en_GH/address/street_address.js +3 -0
  79. package/lib/locales/en_GH/address/street_name.js +4 -0
  80. package/lib/locales/en_GH/address/street_prefix.js +3 -0
  81. package/lib/locales/en_GH/address/street_suffix.js +10 -0
  82. package/lib/locales/en_GH/company/index.js +4 -0
  83. package/lib/locales/en_GH/company/name.js +4 -0
  84. package/lib/locales/en_GH/company/suffix.js +4 -0
  85. package/lib/locales/en_GH/index.js +8 -0
  86. package/lib/locales/en_GH/internet/domain_suffix.js +11 -0
  87. package/lib/locales/en_GH/internet/index.js +3 -0
  88. package/lib/locales/en_GH/name/female_first_name.js +146 -0
  89. package/lib/locales/en_GH/name/first_name.js +4 -0
  90. package/lib/locales/en_GH/name/index.js +7 -0
  91. package/lib/locales/en_GH/name/last_name.js +124 -0
  92. package/lib/locales/en_GH/name/male_first_name.js +134 -0
  93. package/lib/locales/en_GH/name/name.js +6 -0
  94. package/lib/locales/en_GH/phone_number/formats.js +28 -0
  95. package/lib/locales/{nep → en_GH}/phone_number/index.js +0 -0
  96. package/lib/locales/en_NG/address/city_prefix.js +525 -525
  97. package/lib/locales/en_NG/address/state.js +37 -37
  98. package/lib/locales/en_NG/name/female_first_name.js +13 -13
  99. package/lib/locales/en_NG/name/first_name.js +33 -33
  100. package/lib/locales/en_NG/name/male_first_name.js +22 -22
  101. package/lib/locales/en_NG/phone_number/formats.js +5 -5
  102. package/lib/locales/en_US/address/postcode_by_state.js +104 -104
  103. package/lib/locales/en_ZA/address/city_prefix.js +14 -14
  104. package/lib/locales/en_ZA/address/state.js +9 -9
  105. package/lib/locales/en_ZA/cell_phone/formats.js +18 -18
  106. package/lib/locales/en_ZA/name/female_first_name.js +292 -292
  107. package/lib/locales/en_ZA/name/first_name.js +539 -539
  108. package/lib/locales/en_ZA/name/male_first_name.js +252 -252
  109. package/lib/locales/es/commerce/color.js +9 -9
  110. package/lib/locales/es/commerce/department.js +19 -19
  111. package/lib/locales/es/commerce/product_name.js +54 -54
  112. package/lib/locales/es/name/female_first_name.js +12 -12
  113. package/lib/locales/es/name/male_first_name.js +17 -17
  114. package/lib/locales/es_MX/address/street.js +39 -39
  115. package/lib/locales/es_MX/commerce/color.js +31 -31
  116. package/lib/locales/es_MX/commerce/department.js +22 -22
  117. package/lib/locales/es_MX/commerce/product_name.js +56 -56
  118. package/lib/locales/es_MX/company/bs_noun.js +44 -44
  119. package/lib/locales/es_MX/company/bs_verb.js +60 -60
  120. package/lib/locales/es_MX/lorem/words.js +268 -268
  121. package/lib/locales/es_MX/name/first_name.js +304 -304
  122. package/lib/locales/es_MX/name/last_name.js +686 -686
  123. package/lib/locales/es_MX/name/title.js +1 -1
  124. package/lib/locales/es_MX/team/creature.js +66 -66
  125. package/lib/locales/fa/name/female_first_name.js +67 -67
  126. package/lib/locales/fa/name/male_first_name.js +74 -74
  127. package/lib/locales/fa/vehicle/model.js +1 -1
  128. package/lib/locales/fi/name/female_first_name.js +50 -50
  129. package/lib/locales/fi/name/first_name.js +100 -100
  130. package/lib/locales/fi/name/last_name.js +50 -50
  131. package/lib/locales/fi/name/male_first_name.js +50 -50
  132. package/lib/locales/fr/address/city_name.js +84 -84
  133. package/lib/locales/fr/address/country.js +195 -0
  134. package/lib/locales/fr/address/index.js +1 -0
  135. package/lib/locales/fr/name/female_first_name.js +451 -451
  136. package/lib/locales/fr/name/first_name.js +3 -0
  137. package/lib/locales/fr/name/index.js +1 -0
  138. package/lib/locales/fr/name/male_first_name.js +496 -496
  139. package/lib/locales/fr_BE/adresses/building_number.js +12 -0
  140. package/lib/locales/fr_BE/adresses/city.js +4 -0
  141. package/lib/locales/fr_BE/adresses/city_prefix.js +265 -0
  142. package/lib/locales/fr_BE/adresses/city_suffix.js +6 -0
  143. package/lib/locales/fr_BE/adresses/default_country.js +3 -0
  144. package/lib/locales/fr_BE/adresses/index.js +25 -0
  145. package/lib/locales/fr_BE/adresses/postcode.js +3 -0
  146. package/lib/locales/fr_BE/adresses/state.js +12 -0
  147. package/lib/locales/fr_BE/adresses/state_abbr.js +11 -0
  148. package/lib/locales/fr_BE/adresses/street_address.js +3 -0
  149. package/lib/locales/fr_BE/adresses/street_name.js +5 -0
  150. package/lib/locales/fr_BE/adresses/street_prefix.js +21 -0
  151. package/lib/locales/fr_BE/adresses/street_suffix.js +212 -0
  152. package/lib/locales/fr_BE/cell_phone/formats.js +34 -0
  153. package/lib/locales/fr_BE/cell_phone/index.js +3 -0
  154. package/lib/locales/fr_BE/index.js +20 -0
  155. package/lib/locales/fr_BE/internet/domain_suffix.js +10 -0
  156. package/lib/locales/fr_BE/internet/free_email.js +6 -0
  157. package/lib/locales/{nep → fr_BE}/internet/index.js +0 -0
  158. package/lib/locales/fr_BE/name/first_name.js +3009 -0
  159. package/lib/locales/fr_BE/name/first_name_female.js +1532 -0
  160. package/lib/locales/fr_BE/name/first_name_male.js +1482 -0
  161. package/lib/locales/fr_BE/name/gender.js +10 -0
  162. package/lib/locales/fr_BE/name/index.js +11 -0
  163. package/lib/locales/fr_BE/name/last_name.js +624 -0
  164. package/lib/locales/fr_BE/name/name.js +8 -0
  165. package/lib/locales/fr_BE/name/prefix.js +6 -0
  166. package/lib/locales/fr_BE/name/suffix.js +8 -0
  167. package/lib/locales/fr_BE/name/title.js +22 -0
  168. package/lib/locales/fr_BE/phone_number/formats.js +93 -0
  169. package/lib/locales/fr_BE/phone_number/index.js +3 -0
  170. package/lib/locales/hr/address/city_name.js +128 -128
  171. package/lib/locales/hr/address/country.js +246 -246
  172. package/lib/locales/hr/address/street.js +375 -375
  173. package/lib/locales/hr/date/month.js +24 -24
  174. package/lib/locales/hr/date/weekday.js +7 -7
  175. package/lib/locales/hr/name/female_first_name.js +238 -238
  176. package/lib/locales/hr/name/first_name.js +409 -409
  177. package/lib/locales/hr/name/last_name.js +11617 -11617
  178. package/lib/locales/hr/name/male_first_name.js +171 -171
  179. package/lib/locales/hr/name/name.js +6 -6
  180. package/lib/locales/hr/name/prefix.js +5 -5
  181. package/lib/locales/hr/name/suffix.js +2 -2
  182. package/lib/locales/hy/address/building_number.js +8 -0
  183. package/lib/locales/hy/address/city.js +4 -0
  184. package/lib/locales/hy/address/city_prefix.js +7 -0
  185. package/lib/locales/hy/address/city_suffix.js +5 -0
  186. package/lib/locales/hy/address/country.js +231 -0
  187. package/lib/locales/hy/address/default_country.js +3 -0
  188. package/lib/locales/hy/address/direction.js +10 -0
  189. package/lib/locales/hy/address/index.js +14 -0
  190. package/lib/locales/hy/address/secondary_address.js +4 -0
  191. package/lib/locales/hy/address/state.js +21 -0
  192. package/lib/locales/hy/address/street_address.js +3 -0
  193. package/lib/locales/hy/address/street_name.js +3 -0
  194. package/lib/locales/hy/address/street_suffix.js +4 -0
  195. package/lib/locales/hy/commerce/color.js +14 -0
  196. package/lib/locales/hy/commerce/index.js +3 -0
  197. package/lib/locales/hy/date/index.js +4 -0
  198. package/lib/locales/hy/date/month.js +30 -0
  199. package/lib/locales/hy/date/weekday.js +21 -0
  200. package/lib/locales/hy/index.js +11 -0
  201. package/lib/locales/hy/internet/domain_suffix.js +9 -0
  202. package/lib/locales/hy/internet/index.js +3 -0
  203. package/lib/locales/hy/lorem/index.js +3 -0
  204. package/lib/locales/hy/lorem/words.js +191 -0
  205. package/lib/locales/hy/name/female_first_name.js +48 -0
  206. package/lib/locales/hy/name/first_name.js +93 -0
  207. package/lib/locales/hy/name/index.js +7 -0
  208. package/lib/locales/hy/name/last_name.js +94 -0
  209. package/lib/locales/hy/name/male_first_name.js +47 -0
  210. package/lib/locales/hy/name/name.js +8 -0
  211. package/lib/locales/hy/phone_number/formats.js +4 -0
  212. package/lib/locales/hy/phone_number/index.js +3 -0
  213. package/lib/locales/id_ID/name/female_first_name.js +45 -1
  214. package/lib/locales/id_ID/name/female_last_name.js +41 -1
  215. package/lib/locales/id_ID/name/male_last_name.js +47 -2
  216. package/lib/locales/it/address/city_name.js +981 -0
  217. package/lib/locales/it/address/index.js +1 -0
  218. package/lib/locales/it/name/last_name.js +2163 -628
  219. package/lib/locales/ja/address/country.js +169 -0
  220. package/lib/locales/ja/address/index.js +1 -0
  221. package/lib/locales/ko/address/postcode.js +2 -1
  222. package/lib/locales/ko/name/first_name.js +2994 -1
  223. package/lib/locales/ko/name/last_name.js +98 -1
  224. package/lib/locales/lv/commerce/product_name.js +14 -14
  225. package/lib/locales/nb_NO/name/index.js +2 -2
  226. package/lib/locales/{nep → ne}/address/city.js +0 -0
  227. package/lib/locales/{nep → ne}/address/default_country.js +0 -0
  228. package/lib/locales/{nep → ne}/address/index.js +0 -0
  229. package/lib/locales/{nep → ne}/address/postcode.js +0 -0
  230. package/lib/locales/{nep → ne}/address/state.js +0 -0
  231. package/lib/locales/{nep → ne}/company/index.js +0 -0
  232. package/lib/locales/{nep → ne}/company/suffix.js +0 -0
  233. package/lib/locales/ne/index.js +8 -0
  234. package/lib/locales/{nep → ne}/internet/domain_suffix.js +0 -0
  235. package/lib/locales/{nep → ne}/internet/free_email.js +0 -0
  236. package/lib/locales/ne/internet/index.js +4 -0
  237. package/lib/locales/{nep → ne}/name/first_name.js +0 -0
  238. package/lib/locales/{nep → ne}/name/index.js +0 -0
  239. package/lib/locales/{nep → ne}/name/last_name.js +0 -0
  240. package/lib/locales/{nep → ne}/phone_number/formats.js +0 -0
  241. package/lib/locales/ne/phone_number/index.js +3 -0
  242. package/lib/locales/nl/address/country.js +5 -7
  243. package/lib/locales/nl/address/secondary_address.js +2 -1
  244. package/lib/locales/nl/address/street_suffix.js +3 -1
  245. package/lib/locales/nl/commerce/color.js +38 -0
  246. package/lib/locales/nl/commerce/department.js +24 -0
  247. package/lib/locales/nl/commerce/index.js +5 -0
  248. package/lib/locales/nl/commerce/product_name.js +72 -0
  249. package/lib/locales/nl/company/suffix.js +5 -2
  250. package/lib/locales/nl/date/index.js +4 -0
  251. package/lib/locales/nl/date/month.js +63 -0
  252. package/lib/locales/nl/date/weekday.js +43 -0
  253. package/lib/locales/nl/hacker/adjective.js +25 -0
  254. package/lib/locales/nl/hacker/index.js +6 -0
  255. package/lib/locales/nl/hacker/noun.js +28 -0
  256. package/lib/locales/nl/hacker/phrase.js +10 -0
  257. package/lib/locales/nl/hacker/verb.js +23 -0
  258. package/lib/locales/nl/index.js +3 -0
  259. package/lib/locales/nl/internet/domain_suffix.js +2 -1
  260. package/lib/locales/nl/name/female_first_name.js +517 -0
  261. package/lib/locales/nl/name/index.js +2 -0
  262. package/lib/locales/nl/name/male_first_name.js +590 -0
  263. package/lib/locales/pl/name/female_first_name.js +176 -0
  264. package/lib/locales/pl/name/first_name.js +3 -410
  265. package/lib/locales/pl/name/male_first_name.js +236 -0
  266. package/lib/locales/pt_BR/address/city_suffix.js +4 -0
  267. package/lib/locales/pt_BR/address/country.js +41 -44
  268. package/lib/locales/pt_BR/address/state_abbr.js +4 -1
  269. package/lib/locales/pt_BR/company/suffix.js +1 -0
  270. package/lib/locales/pt_BR/name/female_first_name.js +82 -0
  271. package/lib/locales/pt_BR/name/index.js +2 -0
  272. package/lib/locales/pt_BR/name/male_first_name.js +90 -0
  273. package/lib/locales/pt_BR/name/name.js +8 -0
  274. package/lib/locales/pt_BR/name/prefix.js +2 -1
  275. package/lib/locales/pt_PT/phone_number/formats.js +1 -0
  276. package/lib/locales/ro/address/city.js +300 -300
  277. package/lib/locales/ro/address/county.js +42 -42
  278. package/lib/locales/ro/address/state.js +42 -42
  279. package/lib/locales/ro/address/state_abbr.js +42 -42
  280. package/lib/locales/ro/address/street_address.js +1 -1
  281. package/lib/locales/ro/address/street_suffix.js +3 -3
  282. package/lib/locales/ro/address/streets.js +100 -100
  283. package/lib/locales/ro/cell_phone/formats.js +59 -59
  284. package/lib/locales/ro/internet/domain_suffix.js +19 -19
  285. package/lib/locales/ro/internet/index.js +0 -1
  286. package/lib/locales/ro/name/female_first_name.js +387 -387
  287. package/lib/locales/ro/name/last_name.js +300 -300
  288. package/lib/locales/ro/name/male_first_name.js +288 -288
  289. package/lib/locales/ro/name/name.js +32 -32
  290. package/lib/locales/ro/name/prefix.js +3 -3
  291. package/lib/locales/ro/name/suffix.js +2 -2
  292. package/lib/locales/ro/phone_number/formats.js +82 -82
  293. package/lib/locales/sk/address/index.js +0 -1
  294. package/lib/locales/tr/name/female_first_name.js +416 -0
  295. package/lib/locales/tr/name/index.js +2 -0
  296. package/lib/locales/tr/name/male_first_name.js +754 -0
  297. package/lib/locales/tr/name/name.js +2 -2
  298. package/lib/locales/vi/name/female_first_name.js +1312 -0
  299. package/lib/locales/vi/name/first_name.js +3 -28
  300. package/lib/locales/vi/name/index.js +5 -3
  301. package/lib/locales/vi/name/last_name.js +1 -48
  302. package/lib/locales/vi/name/male_first_name.js +1227 -0
  303. package/lib/locales/vi/name/name.js +3 -2
  304. package/lib/locales/zu_ZA/name/female_first_name.js +50 -50
  305. package/lib/locales/zu_ZA/name/first_name.js +100 -100
  306. package/lib/locales/zu_ZA/name/last_name.js +100 -100
  307. package/lib/locales/zu_ZA/name/male_first_name.js +51 -51
  308. package/lib/locales.js +2 -1
  309. package/lib/lorem.js +25 -25
  310. package/lib/mersenne.js +31 -0
  311. package/lib/music.js +9 -9
  312. package/lib/name.js +36 -32
  313. package/lib/phone_number.js +4 -4
  314. package/lib/random.js +138 -150
  315. package/lib/system.js +114 -63
  316. package/lib/time.js +1 -1
  317. package/lib/vehicle.js +38 -4
  318. package/locale/ReadMe.md +1 -1
  319. package/locale/en.js +1 -1
  320. package/locale/en_GH.js +5 -0
  321. package/locale/hy.js +5 -0
  322. package/locale/ne.js +5 -0
  323. package/package.json +4 -3
  324. package/vendor/mersenne.js +194 -222
  325. package/vendor/user-agent.js +155 -155
  326. package/.jshintrc +0 -87
  327. package/lib/locales/cz/address/time_zone.js +0 -145
  328. package/lib/locales/el/internet/avatar_uri.js +0 -1256
  329. package/lib/locales/nep/index.js +0 -8
  330. package/lib/locales/ro/internet/avatar_uri.js +0 -1265
  331. package/lib/locales/sk/address/time_zone.js +0 -145
  332. package/locale/nep.js +0 -5
@@ -30,179 +30,179 @@ If we meet some day, and you think this stuff is worth it, you can buy me a beer
30
30
 
31
31
  exports.generate = function generate(faker) {
32
32
 
33
- function rnd(a, b) {
34
- //calling rnd() with no arguments is identical to rnd(0, 100)
35
- a = a || 0;
36
- b = b || 100;
33
+ function rnd(a, b) {
34
+ //calling rnd() with no arguments is identical to rnd(0, 100)
35
+ a = a || 0;
36
+ b = b || 100;
37
37
 
38
- if (typeof b === 'number' && typeof a === 'number') {
38
+ if (typeof b === 'number' && typeof a === 'number') {
39
39
 
40
- // 9/2018 - Added faker random to ensure mersenne and seed
41
- return faker.random.number({ min: a, max: b});
40
+ // 9/2018 - Added faker random to ensure mersenne and seed
41
+ return faker.datatype.number({ min: a, max: b});
42
42
 
43
- }
44
-
45
- if (Object.prototype.toString.call(a) === "[object Array]") {
46
- //returns a random element from array (a), even weighting
47
- return faker.random.arrayElement(a);
48
- }
49
-
50
- if (a && typeof a === 'object') {
51
- //returns a random key from the passed object; keys are weighted by the decimal probability in their value
52
- return (function (obj) {
53
- var rand = rnd(0, 100) / 100, min = 0, max = 0, key, return_val;
54
-
55
- for (key in obj) {
56
- if (obj.hasOwnProperty(key)) {
57
- max = obj[key] + min;
58
- return_val = key;
59
- if (rand >= min && rand <= max) {
60
- break;
61
- }
62
- min = min + obj[key];
63
- }
64
- }
65
-
66
- return return_val;
67
- }(a));
68
- }
69
-
70
- throw new TypeError('Invalid arguments passed to rnd. (' + (b ? a + ', ' + b : a) + ')');
71
43
  }
72
44
 
73
- function randomLang() {
74
- return rnd(['AB', 'AF', 'AN', 'AR', 'AS', 'AZ', 'BE', 'BG', 'BN', 'BO', 'BR', 'BS', 'CA', 'CE', 'CO', 'CS',
75
- 'CU', 'CY', 'DA', 'DE', 'EL', 'EN', 'EO', 'ES', 'ET', 'EU', 'FA', 'FI', 'FJ', 'FO', 'FR', 'FY',
76
- 'GA', 'GD', 'GL', 'GV', 'HE', 'HI', 'HR', 'HT', 'HU', 'HY', 'ID', 'IS', 'IT', 'JA', 'JV', 'KA',
77
- 'KG', 'KO', 'KU', 'KW', 'KY', 'LA', 'LB', 'LI', 'LN', 'LT', 'LV', 'MG', 'MK', 'MN', 'MO', 'MS',
78
- 'MT', 'MY', 'NB', 'NE', 'NL', 'NN', 'NO', 'OC', 'PL', 'PT', 'RM', 'RO', 'RU', 'SC', 'SE', 'SK',
79
- 'SL', 'SO', 'SQ', 'SR', 'SV', 'SW', 'TK', 'TR', 'TY', 'UK', 'UR', 'UZ', 'VI', 'VO', 'YI', 'ZH']);
45
+ if (Object.prototype.toString.call(a) === "[object Array]") {
46
+ //returns a random element from array (a), even weighting
47
+ return faker.random.arrayElement(a);
80
48
  }
81
49
 
82
- function randomBrowserAndOS() {
83
- var browser = rnd({
84
- chrome: .45132810566,
85
- iexplorer: .27477061836,
86
- firefox: .19384170608,
87
- safari: .06186781118,
88
- opera: .01574236955
89
- }),
90
- os = {
91
- chrome: {win: .89, mac: .09 , lin: .02},
92
- firefox: {win: .83, mac: .16, lin: .01},
93
- opera: {win: .91, mac: .03 , lin: .06},
94
- safari: {win: .04 , mac: .96 },
95
- iexplorer: ['win']
96
- };
97
-
98
- return [browser, rnd(os[browser])];
99
- }
100
-
101
- function randomProc(arch) {
102
- var procs = {
103
- lin:['i686', 'x86_64'],
104
- mac: {'Intel' : .48, 'PPC': .01, 'U; Intel':.48, 'U; PPC' :.01},
105
- win:['', 'WOW64', 'Win64; x64']
106
- };
107
- return rnd(procs[arch]);
108
- }
109
-
110
- function randomRevision(dots) {
111
- var return_val = '';
112
- //generate a random revision
113
- //dots = 2 returns .x.y where x & y are between 0 and 9
114
- for (var x = 0; x < dots; x++) {
115
- return_val += '.' + rnd(0, 9);
50
+ if (a && typeof a === 'object') {
51
+ //returns a random key from the passed object; keys are weighted by the decimal probability in their value
52
+ return (function (obj) {
53
+ var rand = rnd(0, 100) / 100, min = 0, max = 0, key, return_val;
54
+
55
+ for (key in obj) {
56
+ if (obj.hasOwnProperty(key)) {
57
+ max = obj[key] + min;
58
+ return_val = key;
59
+ if (rand >= min && rand <= max) {
60
+ break;
61
+ }
62
+ min = min + obj[key];
63
+ }
116
64
  }
65
+
117
66
  return return_val;
67
+ }(a));
118
68
  }
119
69
 
120
- var version_string = {
121
- net: function () {
122
- return [rnd(1, 4), rnd(0, 9), rnd(10000, 99999), rnd(0, 9)].join('.');
123
- },
124
- nt: function () {
125
- return rnd(5, 6) + '.' + rnd(0, 3);
126
- },
127
- ie: function () {
128
- return rnd(7, 11);
129
- },
130
- trident: function () {
131
- return rnd(3, 7) + '.' + rnd(0, 1);
132
- },
133
- osx: function (delim) {
134
- return [10, rnd(5, 10), rnd(0, 9)].join(delim || '.');
135
- },
136
- chrome: function () {
137
- return [rnd(13, 39), 0, rnd(800, 899), 0].join('.');
138
- },
139
- presto: function () {
140
- return '2.9.' + rnd(160, 190);
141
- },
142
- presto2: function () {
143
- return rnd(10, 12) + '.00';
144
- },
145
- safari: function () {
146
- return rnd(531, 538) + '.' + rnd(0, 2) + '.' + rnd(0,2);
147
- }
70
+ throw new TypeError('Invalid arguments passed to rnd. (' + (b ? a + ', ' + b : a) + ')');
71
+ }
72
+
73
+ function randomLang() {
74
+ return rnd(['AB', 'AF', 'AN', 'AR', 'AS', 'AZ', 'BE', 'BG', 'BN', 'BO', 'BR', 'BS', 'CA', 'CE', 'CO', 'CS',
75
+ 'CU', 'CY', 'DA', 'DE', 'EL', 'EN', 'EO', 'ES', 'ET', 'EU', 'FA', 'FI', 'FJ', 'FO', 'FR', 'FY',
76
+ 'GA', 'GD', 'GL', 'GV', 'HE', 'HI', 'HR', 'HT', 'HU', 'HY', 'ID', 'IS', 'IT', 'JA', 'JV', 'KA',
77
+ 'KG', 'KO', 'KU', 'KW', 'KY', 'LA', 'LB', 'LI', 'LN', 'LT', 'LV', 'MG', 'MK', 'MN', 'MO', 'MS',
78
+ 'MT', 'MY', 'NB', 'NE', 'NL', 'NN', 'NO', 'OC', 'PL', 'PT', 'RM', 'RO', 'RU', 'SC', 'SE', 'SK',
79
+ 'SL', 'SO', 'SQ', 'SR', 'SV', 'SW', 'TK', 'TR', 'TY', 'UK', 'UR', 'UZ', 'VI', 'VO', 'YI', 'ZH']);
80
+ }
81
+
82
+ function randomBrowserAndOS() {
83
+ var browser = rnd({
84
+ chrome: .45132810566,
85
+ iexplorer: .27477061836,
86
+ firefox: .19384170608,
87
+ safari: .06186781118,
88
+ opera: .01574236955
89
+ }),
90
+ os = {
91
+ chrome: {win: .89, mac: .09 , lin: .02},
92
+ firefox: {win: .83, mac: .16, lin: .01},
93
+ opera: {win: .91, mac: .03 , lin: .06},
94
+ safari: {win: .04 , mac: .96 },
95
+ iexplorer: ['win']
96
+ };
97
+
98
+ return [browser, rnd(os[browser])];
99
+ }
100
+
101
+ function randomProc(arch) {
102
+ var procs = {
103
+ lin:['i686', 'x86_64'],
104
+ mac: {'Intel' : .48, 'PPC': .01, 'U; Intel':.48, 'U; PPC' :.01},
105
+ win:['', 'WOW64', 'Win64; x64']
148
106
  };
149
-
150
- var browser = {
151
- firefox: function firefox(arch) {
152
- //https://developer.mozilla.org/en-US/docs/Gecko_user_agent_string_reference
153
- var firefox_ver = rnd(5, 15) + randomRevision(2),
154
- gecko_ver = 'Gecko/20100101 Firefox/' + firefox_ver,
155
- proc = randomProc(arch),
156
- os_ver = (arch === 'win') ? '(Windows NT ' + version_string.nt() + ((proc) ? '; ' + proc : '')
157
- : (arch === 'mac') ? '(Macintosh; ' + proc + ' Mac OS X ' + version_string.osx()
158
- : '(X11; Linux ' + proc;
159
-
160
- return 'Mozilla/5.0 ' + os_ver + '; rv:' + firefox_ver.slice(0, -2) + ') ' + gecko_ver;
161
- },
162
-
163
- iexplorer: function iexplorer() {
164
- var ver = version_string.ie();
165
-
166
- if (ver >= 11) {
167
- //http://msdn.microsoft.com/en-us/library/ie/hh869301(v=vs.85).aspx
168
- return 'Mozilla/5.0 (Windows NT 6.' + rnd(1,3) + '; Trident/7.0; ' + rnd(['Touch; ', '']) + 'rv:11.0) like Gecko';
169
- }
170
-
171
- //http://msdn.microsoft.com/en-us/library/ie/ms537503(v=vs.85).aspx
172
- return 'Mozilla/5.0 (compatible; MSIE ' + ver + '.0; Windows NT ' + version_string.nt() + '; Trident/' +
107
+ return rnd(procs[arch]);
108
+ }
109
+
110
+ function randomRevision(dots) {
111
+ var return_val = '';
112
+ //generate a random revision
113
+ //dots = 2 returns .x.y where x & y are between 0 and 9
114
+ for (var x = 0; x < dots; x++) {
115
+ return_val += '.' + rnd(0, 9);
116
+ }
117
+ return return_val;
118
+ }
119
+
120
+ var version_string = {
121
+ net: function () {
122
+ return [rnd(1, 4), rnd(0, 9), rnd(10000, 99999), rnd(0, 9)].join('.');
123
+ },
124
+ nt: function () {
125
+ return rnd(5, 6) + '.' + rnd(0, 3);
126
+ },
127
+ ie: function () {
128
+ return rnd(7, 11);
129
+ },
130
+ trident: function () {
131
+ return rnd(3, 7) + '.' + rnd(0, 1);
132
+ },
133
+ osx: function (delim) {
134
+ return [10, rnd(5, 10), rnd(0, 9)].join(delim || '.');
135
+ },
136
+ chrome: function () {
137
+ return [rnd(13, 39), 0, rnd(800, 899), 0].join('.');
138
+ },
139
+ presto: function () {
140
+ return '2.9.' + rnd(160, 190);
141
+ },
142
+ presto2: function () {
143
+ return rnd(10, 12) + '.00';
144
+ },
145
+ safari: function () {
146
+ return rnd(531, 538) + '.' + rnd(0, 2) + '.' + rnd(0,2);
147
+ }
148
+ };
149
+
150
+ var browser = {
151
+ firefox: function firefox(arch) {
152
+ //https://developer.mozilla.org/en-US/docs/Gecko_user_agent_string_reference
153
+ var firefox_ver = rnd(5, 15) + randomRevision(2),
154
+ gecko_ver = 'Gecko/20100101 Firefox/' + firefox_ver,
155
+ proc = randomProc(arch),
156
+ os_ver = (arch === 'win') ? '(Windows NT ' + version_string.nt() + ((proc) ? '; ' + proc : '')
157
+ : (arch === 'mac') ? '(Macintosh; ' + proc + ' Mac OS X ' + version_string.osx()
158
+ : '(X11; Linux ' + proc;
159
+
160
+ return 'Mozilla/5.0 ' + os_ver + '; rv:' + firefox_ver.slice(0, -2) + ') ' + gecko_ver;
161
+ },
162
+
163
+ iexplorer: function iexplorer() {
164
+ var ver = version_string.ie();
165
+
166
+ if (ver >= 11) {
167
+ //http://msdn.microsoft.com/en-us/library/ie/hh869301(v=vs.85).aspx
168
+ return 'Mozilla/5.0 (Windows NT 6.' + rnd(1,3) + '; Trident/7.0; ' + rnd(['Touch; ', '']) + 'rv:11.0) like Gecko';
169
+ }
170
+
171
+ //http://msdn.microsoft.com/en-us/library/ie/ms537503(v=vs.85).aspx
172
+ return 'Mozilla/5.0 (compatible; MSIE ' + ver + '.0; Windows NT ' + version_string.nt() + '; Trident/' +
173
173
  version_string.trident() + ((rnd(0, 1) === 1) ? '; .NET CLR ' + version_string.net() : '') + ')';
174
- },
175
-
176
- opera: function opera(arch) {
177
- //http://www.opera.com/docs/history/
178
- var presto_ver = ' Presto/' + version_string.presto() + ' Version/' + version_string.presto2() + ')',
179
- os_ver = (arch === 'win') ? '(Windows NT ' + version_string.nt() + '; U; ' + randomLang() + presto_ver
180
- : (arch === 'lin') ? '(X11; Linux ' + randomProc(arch) + '; U; ' + randomLang() + presto_ver
181
- : '(Macintosh; Intel Mac OS X ' + version_string.osx() + ' U; ' + randomLang() + ' Presto/' +
174
+ },
175
+
176
+ opera: function opera(arch) {
177
+ //http://www.opera.com/docs/history/
178
+ var presto_ver = ' Presto/' + version_string.presto() + ' Version/' + version_string.presto2() + ')',
179
+ os_ver = (arch === 'win') ? '(Windows NT ' + version_string.nt() + '; U; ' + randomLang() + presto_ver
180
+ : (arch === 'lin') ? '(X11; Linux ' + randomProc(arch) + '; U; ' + randomLang() + presto_ver
181
+ : '(Macintosh; Intel Mac OS X ' + version_string.osx() + ' U; ' + randomLang() + ' Presto/' +
182
182
  version_string.presto() + ' Version/' + version_string.presto2() + ')';
183
183
 
184
- return 'Opera/' + rnd(9, 14) + '.' + rnd(0, 99) + ' ' + os_ver;
185
- },
184
+ return 'Opera/' + rnd(9, 14) + '.' + rnd(0, 99) + ' ' + os_ver;
185
+ },
186
186
 
187
- safari: function safari(arch) {
188
- var safari = version_string.safari(),
189
- ver = rnd(4, 7) + '.' + rnd(0,1) + '.' + rnd(0,10),
190
- os_ver = (arch === 'mac') ? '(Macintosh; ' + randomProc('mac') + ' Mac OS X '+ version_string.osx('_') + ' rv:' + rnd(2, 6) + '.0; '+ randomLang() + ') '
191
- : '(Windows; U; Windows NT ' + version_string.nt() + ')';
187
+ safari: function safari(arch) {
188
+ var safari = version_string.safari(),
189
+ ver = rnd(4, 7) + '.' + rnd(0,1) + '.' + rnd(0,10),
190
+ os_ver = (arch === 'mac') ? '(Macintosh; ' + randomProc('mac') + ' Mac OS X '+ version_string.osx('_') + ' rv:' + rnd(2, 6) + '.0; '+ randomLang() + ') '
191
+ : '(Windows; U; Windows NT ' + version_string.nt() + ')';
192
192
 
193
- return 'Mozilla/5.0 ' + os_ver + 'AppleWebKit/' + safari + ' (KHTML, like Gecko) Version/' + ver + ' Safari/' + safari;
194
- },
193
+ return 'Mozilla/5.0 ' + os_ver + 'AppleWebKit/' + safari + ' (KHTML, like Gecko) Version/' + ver + ' Safari/' + safari;
194
+ },
195
195
 
196
- chrome: function chrome(arch) {
197
- var safari = version_string.safari(),
198
- os_ver = (arch === 'mac') ? '(Macintosh; ' + randomProc('mac') + ' Mac OS X ' + version_string.osx('_') + ') '
199
- : (arch === 'win') ? '(Windows; U; Windows NT ' + version_string.nt() + ')'
200
- : '(X11; Linux ' + randomProc(arch);
196
+ chrome: function chrome(arch) {
197
+ var safari = version_string.safari(),
198
+ os_ver = (arch === 'mac') ? '(Macintosh; ' + randomProc('mac') + ' Mac OS X ' + version_string.osx('_') + ') '
199
+ : (arch === 'win') ? '(Windows; U; Windows NT ' + version_string.nt() + ')'
200
+ : '(X11; Linux ' + randomProc(arch);
201
201
 
202
- return 'Mozilla/5.0 ' + os_ver + ' AppleWebKit/' + safari + ' (KHTML, like Gecko) Chrome/' + version_string.chrome() + ' Safari/' + safari;
203
- }
204
- };
202
+ return 'Mozilla/5.0 ' + os_ver + ' AppleWebKit/' + safari + ' (KHTML, like Gecko) Chrome/' + version_string.chrome() + ' Safari/' + safari;
203
+ }
204
+ };
205
205
 
206
- var random = randomBrowserAndOS();
207
- return browser[random[0]](random[1]);
206
+ var random = randomBrowserAndOS();
207
+ return browser[random[0]](random[1]);
208
208
  };
package/.jshintrc DELETED
@@ -1,87 +0,0 @@
1
- {
2
- // Settings
3
- "passfail" : false, // Stop on first error.
4
- "maxerr" : 500, // Maximum errors before stopping.
5
- "multistr" : true,
6
-
7
-
8
- // Predefined globals whom JSHint will ignore.
9
- "browser" : true, // Standard browser globals e.g. `window`, `document`.
10
-
11
- "node" : false,
12
- "rhino" : false,
13
- "couch" : false,
14
- "wsh" : true, // Windows Scripting Host.
15
-
16
- "jquery" : true,
17
- "prototypejs" : false,
18
- "mootools" : false,
19
- "dojo" : false,
20
-
21
- "predef" : [ // Extra globals.
22
- "__dirname",
23
- "Buffer",
24
- "event",
25
- "exports",
26
- "global",
27
- "logger",
28
- "module",
29
- "process",
30
- "require",
31
-
32
- "after",
33
- "afterEach",
34
- "before",
35
- "beforeEach",
36
- "context",
37
- "describe",
38
- "it"
39
- ],
40
-
41
- // Development.
42
- "debug" : false, // Allow debugger statements e.g. browser breakpoints.
43
- "devel" : true, // Allow development statements e.g. `console.log();`.
44
-
45
-
46
- // EcmaScript 5.
47
- "es5" : false, // Allow EcmaScript 5 syntax.
48
- "strict" : false, // Require `use strict` pragma in every file.
49
- "globalstrict" : false, // Allow global "use strict" (also enables 'strict').
50
-
51
-
52
- "asi" : false, // Tolerate Automatic Semicolon Insertion (no semicolons).
53
- "laxbreak" : false, // Tolerate unsafe line breaks e.g. `return [\n] x` without semicolons.
54
- "bitwise" : true, // Prohibit bitwise operators (&, |, ^, etc.).
55
- "boss" : false, // Tolerate assignments inside if, for & while. Usually conditions & loops are for comparison, not assignments.
56
- "curly" : true, // Require {} for every new block or scope.
57
- "eqeqeq" : false, // Require triple equals i.e. `===`.
58
- "eqnull" : false, // Tolerate use of `== null`.
59
- "evil" : false, // Tolerate use of `eval`.
60
- "expr" : false, // Tolerate `ExpressionStatement` as Programs.
61
- "forin" : false, // Tolerate `for in` loops without `hasOwnProperty`.
62
- "immed" : true, // Require immediate invocations to be wrapped in parens e.g. `( function(){}() );`
63
- "latedef" : true, // Prohibit variable use before definition.
64
- "loopfunc" : true, // Allow functions to be defined within loops.
65
- //"maxparams" : 4,
66
- //"maxdepth" : 5,
67
- //"maxcomplexity" : 10,
68
- "noarg" : true, // Prohibit use of `arguments.caller` and `arguments.callee`.
69
- "regexp" : false, // Prohibit `.` and `[^...]` in regular expressions.
70
- "regexdash" : false, // Tolerate unescaped last dash i.e. `[-...]`.
71
- "scripturl" : true, // Tolerate script-targeted URLs.
72
- "shadow" : false, // Allows re-define variables later in code e.g. `var x=1; x=2;`.
73
- "supernew" : false, // Tolerate `new function () { ... };` and `new Object;`.
74
- "undef" : true, // Require all non-global variables be declared before they are used.
75
-
76
-
77
- "newcap" : false, // Require capitalization of all constructor functions e.g. `new F()`.
78
- "noempty" : true, // Prohibit use of empty blocks.
79
- "nonew" : false, // Prohibit use of constructors for side-effects.
80
- "nomen" : false, // Prohibit use of initial or trailing underbars in names.
81
- "onevar" : false, // Allow only one `var` statement per function.
82
- "plusplus" : false, // Prohibit use of `++` & `--`.
83
- "sub" : true, // Tolerate all forms of subscript notation besides dot notation e.g. `dict['key']` instead of `dict.key`.
84
- "trailing" : true, // Prohibit trailing whitespaces. (only works if white is 'true')
85
- "white" : true, // Check against strict whitespace and indentation rules.
86
- "indent" : 4 //
87
- }
@@ -1,145 +0,0 @@
1
- module["exports"] = [
2
- "Pacific/Midway",
3
- "Pacific/Pago_Pago",
4
- "Pacific/Honolulu",
5
- "America/Juneau",
6
- "America/Los_Angeles",
7
- "America/Tijuana",
8
- "America/Denver",
9
- "America/Phoenix",
10
- "America/Chihuahua",
11
- "America/Mazatlan",
12
- "America/Chicago",
13
- "America/Regina",
14
- "America/Mexico_City",
15
- "America/Mexico_City",
16
- "America/Monterrey",
17
- "America/Guatemala",
18
- "America/New_York",
19
- "America/Indiana/Indianapolis",
20
- "America/Bogota",
21
- "America/Lima",
22
- "America/Lima",
23
- "America/Halifax",
24
- "America/Caracas",
25
- "America/La_Paz",
26
- "America/Santiago",
27
- "America/St_Johns",
28
- "America/Sao_Paulo",
29
- "America/Argentina/Buenos_Aires",
30
- "America/Guyana",
31
- "America/Godthab",
32
- "Atlantic/South_Georgia",
33
- "Atlantic/Azores",
34
- "Atlantic/Cape_Verde",
35
- "Europe/Dublin",
36
- "Europe/London",
37
- "Europe/Lisbon",
38
- "Europe/London",
39
- "Africa/Casablanca",
40
- "Africa/Monrovia",
41
- "Etc/UTC",
42
- "Europe/Belgrade",
43
- "Europe/Bratislava",
44
- "Europe/Budapest",
45
- "Europe/Ljubljana",
46
- "Europe/Prague",
47
- "Europe/Sarajevo",
48
- "Europe/Skopje",
49
- "Europe/Warsaw",
50
- "Europe/Zagreb",
51
- "Europe/Brussels",
52
- "Europe/Copenhagen",
53
- "Europe/Madrid",
54
- "Europe/Paris",
55
- "Europe/Amsterdam",
56
- "Europe/Berlin",
57
- "Europe/Berlin",
58
- "Europe/Rome",
59
- "Europe/Stockholm",
60
- "Europe/Vienna",
61
- "Africa/Algiers",
62
- "Europe/Bucharest",
63
- "Africa/Cairo",
64
- "Europe/Helsinki",
65
- "Europe/Kiev",
66
- "Europe/Riga",
67
- "Europe/Sofia",
68
- "Europe/Tallinn",
69
- "Europe/Vilnius",
70
- "Europe/Athens",
71
- "Europe/Istanbul",
72
- "Europe/Minsk",
73
- "Asia/Jerusalem",
74
- "Africa/Harare",
75
- "Africa/Johannesburg",
76
- "Europe/Moscow",
77
- "Europe/Moscow",
78
- "Europe/Moscow",
79
- "Asia/Kuwait",
80
- "Asia/Riyadh",
81
- "Africa/Nairobi",
82
- "Asia/Baghdad",
83
- "Asia/Tehran",
84
- "Asia/Muscat",
85
- "Asia/Muscat",
86
- "Asia/Baku",
87
- "Asia/Tbilisi",
88
- "Asia/Yerevan",
89
- "Asia/Kabul",
90
- "Asia/Yekaterinburg",
91
- "Asia/Karachi",
92
- "Asia/Karachi",
93
- "Asia/Tashkent",
94
- "Asia/Kolkata",
95
- "Asia/Kolkata",
96
- "Asia/Kolkata",
97
- "Asia/Kolkata",
98
- "Asia/Kathmandu",
99
- "Asia/Dhaka",
100
- "Asia/Dhaka",
101
- "Asia/Colombo",
102
- "Asia/Almaty",
103
- "Asia/Novosibirsk",
104
- "Asia/Rangoon",
105
- "Asia/Bangkok",
106
- "Asia/Bangkok",
107
- "Asia/Jakarta",
108
- "Asia/Krasnoyarsk",
109
- "Asia/Shanghai",
110
- "Asia/Chongqing",
111
- "Asia/Hong_Kong",
112
- "Asia/Urumqi",
113
- "Asia/Kuala_Lumpur",
114
- "Asia/Singapore",
115
- "Asia/Taipei",
116
- "Australia/Perth",
117
- "Asia/Irkutsk",
118
- "Asia/Ulaanbaatar",
119
- "Asia/Seoul",
120
- "Asia/Tokyo",
121
- "Asia/Tokyo",
122
- "Asia/Tokyo",
123
- "Asia/Yakutsk",
124
- "Australia/Darwin",
125
- "Australia/Adelaide",
126
- "Australia/Melbourne",
127
- "Australia/Melbourne",
128
- "Australia/Sydney",
129
- "Australia/Brisbane",
130
- "Australia/Hobart",
131
- "Asia/Vladivostok",
132
- "Pacific/Guam",
133
- "Pacific/Port_Moresby",
134
- "Asia/Magadan",
135
- "Asia/Magadan",
136
- "Pacific/Noumea",
137
- "Pacific/Fiji",
138
- "Asia/Kamchatka",
139
- "Pacific/Majuro",
140
- "Pacific/Auckland",
141
- "Pacific/Auckland",
142
- "Pacific/Tongatapu",
143
- "Pacific/Fakaofo",
144
- "Pacific/Apia"
145
- ];