UNPKG

1.03 kBMarkdownView Raw
1# n
2
3```js
4// usage
5chance.n(chance.email, 5)
6chance.n(chance.email, 5, { domain: "socialradar.com" })
7```
8
9Provide any function that generates random stuff (usually another **Chance** function) and a number and `n()` will generate an array of items with a length matching the length you specified.
10
11For example, to generate 5 email addresses:
12
13```js
14chance.n(chance.email, 5);
15=> [ 'nese@me.gov',
16'tukvogi@novew.co.uk',
17'worzi@jotok.edu',
18'wicumafom@lalu.edu',
19'hifebwo@abecusa.com' ]
20```
21
22Any options that would be sent to the random function can be added following the number.
23
24For example, `chance.email()` has options which can be specified, so you can generate 5 emails with a known domain as follows:
25
26```js
27chance.n(chance.email, 5, { domain: "socialradar.com" })
28=> [ 'nuvvu@socialradar.com',
29'icolul@socialradar.com',
30'rig@socialradar.com',
31'ca@socialradar.com',
32'uc@socialradar.com' ]
33```
34
35Note, these items are not guaranteed to be unique. If that is the intent, see [`chance.unique()`](http://chancejs.com/#unique)