-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
84 lines (82 loc) · 1.89 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
const _ = require("underscore");
const fakeData = {
userData: require("./data/userdata.json"),
users: function (count) {
const users = _.sample(this.userData, count);
return users;
},
firstname: function (count) {
const users = this.users(count);
let firstname = [];
users.map((i) => {
firstname.push(i.first_name);
});
return firstname;
},
lastname: function (count) {
const users = this.users(count);
let lastname = [];
users.map((i) => {
lastname.push(i.lastname);
});
return lastname;
},
emails: function (count) {
const users = this.users(count);
let emails = [];
users.map((i) => {
emails.push(i.email);
});
return emails;
},
username: function (count) {
const users = this.users(count);
let username = [];
users.map((i) => {
username.push(i.username);
});
return username;
},
phone: function (count) {
const users = this.users(count);
let phone = [];
users.map((i) => {
phone.push(i.phone_number);
});
return phone;
},
location: function (count) {
const users = this.users(count);
let location = [];
users.map((i) => {
location.push(i.location);
});
return location;
},
birthdate: function (count) {
const users = this.users(count);
let birthdate = [];
users.map((i) => {
birthdate.push(i.birthdate);
});
return birthdate;
},
obj: function (count, options) {
let properties = Object.keys(options);
console.log(properties);
const data = {};
properties.forEach(function (item) {
data[item] = this[item](count);
}, this);
const result = [];
_.times(count, function (i) {
const item = {};
Object.keys(data).forEach(function (key) {
item[key] = data[key][i];
});
result.push(item);
});
return result;
},
};
module.exports = fakeData;