-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.js
60 lines (50 loc) · 1.25 KB
/
demo.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
const compadre = require('./index');
let c = new compadre();
const name = c.generate();
console.log('\x1b[33m%s\x1b[0m', 'Basic usage');
console.log(name);
console.log('\n');
const superheroes = {
adjectives: ['super', 'captain', 'awesome'],
nouns: ['metal', 'gear', 'solid'],
suffix: 'Man',
glue: '',
unique: false,
up: true,
};
c = new compadre(superheroes);
const name1 = c.generate();
const name2 = c.generate();
const name3 = c.generate();
console.log('\x1b[33m%s\x1b[0m', 'Superheroes');
console.log(name1);
console.log(name2);
console.log(name3);
console.log('\n');
c = new compadre({prefix: 'l33t'});
const name4 = c.generate();
console.log('\x1b[33m%s\x1b[0m', 'Prefix l33t');
console.log(name4);
console.log('\n');
c = new compadre({glue: '**'});
const name5 = c.generate();
console.log('\x1b[33m%s\x1b[0m', 'Glue **');
console.log(name5);
console.log('\n');
const basic = {
adjectives: [],
nouns: ['man', 'Bear', 'pig'],
up: true,
unique: true,
fallback: () => `${Date.now()}-Anon`,
};
c = new compadre(basic);
console.log('\x1b[33m%s\x1b[0m', 'Callback and seeding');
for (let index = 0; index <= 5; index++) {
let word = c.generate();
if (/Anon/.test(word)) {
c.seed('annie');
}
console.log(word);
};
console.log('\n');