-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtweetBank.js
58 lines (49 loc) · 1.57 KB
/
tweetBank.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
const _ = require('lodash'); // library of functions
var data = [];
// name: 'Bob',
// age: 100
// }, {
// name: 'JRBob',
// age: 10
// }, {
// name: 'SRBob',
// age: 1000
// }];
function add(name, content) {
data.push({
name: name,
content: content,
id: data.length // added unique id for each user -> now tweets can be linked to this id
})
}
function list() {
return _.cloneDeep(data);
}
function find(properties) {
return _.cloneDeep(_.filter(data, properties));
}
module.exports = {
add: add,
list: list,
find: find
}
const randArrayEl = function (arr) {
return arr[Math.floor(Math.random() * arr.length)];
};
const getFakeName = function () {
const fakeFirsts = ['Nimit', 'David', 'Shanna', 'Emily', 'Scott', 'Karen', 'Ben', 'Dan', 'Ashi', 'Kate', 'Omri', 'Gabriel', 'Joe', 'Geoff'];
const fakeLasts = ['Hashington', 'Stackson', 'McQueue', 'OLogn', 'Ternary', 'Claujure', 'Dunderproto', 'Binder', 'Docsreader', 'Ecma'];
return randArrayEl(fakeFirsts) + " " + randArrayEl(fakeLasts);
};
const getFakeTweet = function () {
const awesome_adj = ['awesome', 'breathtaking', 'amazing', 'funny', 'sweet', 'cool', 'wonderful', 'mindblowing', 'impressive'];
return "Fullstack Academy is " + randArrayEl(awesome_adj) + "! The instructors are just so " + randArrayEl(awesome_adj) + ". #fullstacklove #codedreams";
};
for (let i = 0; i < 10; i++) {
module.exports.add(getFakeName(), getFakeTweet());
}
// var properties = {
// name: "Bob"
// };
// console.log(find(properties));
//console.log(data);