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