UNPKG

891 BMarkdownView Raw
1# set
2
3```js
4// usage
5chance.set(key, value)
6```
7
8Used for overriding the default data used by Chance.
9
10For example, if instead of the default set of last names (which were pulled from the U.S. census data and therefore obviously American biased), you could replace the data for the first names with something more suited to your task. For example, if you want instead to pick from last names of houses in *A Song of Ice and Fire*, you could do something like:
11
12```js
13chance.set('lastNames', ['Arryn', 'Baratheon', 'Bolton', 'Frey', 'Greyjoy', 'Lannister', 'Martell', 'Stark', 'Targaryen', 'Tully', 'Tyrell']);
14
15// then
16chance.last()
17=> 'Lannister'
18```
19
20This is very handy for internationalization.
21
22Available keys for datasets to override: `firstNames`, `lastNames`, `provinces`, `us_states_and_dc`, `territories`, `armed_forces`, `street_suffixes`, `months`, `cc_types`, `currency_types`
23