UNPKG

724 BJavaScriptView Raw
1const faker = require("faker");
2const _ = require("lodash");
3const moment = require("moment");
4
5const now = moment();
6
7const generate = count =>
8 _.range(count).map((val, index) => {
9 const birthAt = faker.date.between(
10 moment()
11 .subtract(10, "year")
12 .toDate(),
13 moment()
14 .subtract(1, "year")
15 .toDate()
16 );
17
18 const age = now.diff(moment(birthAt), "year");
19
20 return {
21 id: faker.random.uuid(),
22 name: faker.name.lastName(),
23 tag: faker.random.arrayElement(["CAT", "DOG"]),
24 owner: faker.name.firstName(),
25 grade: faker.random.number({ min: 1, max: 5 }),
26 age,
27 birthAt: birthAt.toISOString(),
28 };
29 });
30
31module.exports = generate;