-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpassport-title-generator.js
45 lines (35 loc) · 1 KB
/
passport-title-generator.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
var data = require('./data.json');
var ADJ_COUNT = data.adjs.length,
NOUN_COUNT = data.nouns.length;
var adjPrime = 379,
nounPrime = 2027,
seed = 0,
current = 0;
module.exports = next;
module.exports.next = next;
function next () {
current += 1;
return [
data.adjs[ (seed + (current * adjPrime)) % ADJ_COUNT ],
data.nouns[ (seed + (current * nounPrime)) % NOUN_COUNT ]
];
}
module.exports.originalData = require('./data.json');
module.exports.newData = function (newData) {
current = 0;
data = newData;
ADJ_COUNT = data.adjs.length;
NOUN_COUNT = data.nouns.length;
return true;
}
// these options are only configurable before
// you call `next` for the first time
module.exports.seed = function (newSeed) {
return current === 0 && (seed = newSeed, true);
};
module.exports.adjPrime = function (newPrime) {
return current === 0 && (adjPrime = newPrime, true);
};
module.exports.nounPrime = function (newPrime) {
return current === 0 && (nounPrime = newPrime, true);
};