-
Notifications
You must be signed in to change notification settings - Fork 3
/
tributedemander.js
80 lines (66 loc) · 1.79 KB
/
tributedemander.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
var canonicalizer = require('canonicalizer');
var isEmoji = require('is-emoji');
var probable = require('probable');
function makeDemandForTopic(opts) {
if (isSpecialTopic(opts.topic)) {
return makeDemandForSpecialTopic(opts);
}
var tributeFigure =
opts && opts.tributeFigure ? opts.tributeFigure.toUpperCase() : 'GOD';
var prepositionalPhrase =
opts && opts.prepositionalPhrase
? opts.prepositionalPhrase.toUpperCase()
: 'FOR THE';
var forms;
if (opts.isEmoji) {
var pluralFormArray = [];
for (var i = 0; i < opts.repeatNTimesToPluralize; ++i) {
pluralFormArray.push(opts.topic);
}
forms = [opts.topic, pluralFormArray.join(' ')];
} else {
forms = canonicalizer.getSingularAndPluralForms(opts.topic);
}
var postEmojiSpace = '';
if (opts.isEmoji) {
postEmojiSpace = ' ';
} else {
forms = forms.map(function upperize(s) {
return s.toUpperCase();
});
}
var demand =
forms[1] +
' ' +
postEmojiSpace +
prepositionalPhrase +
' ' +
forms[0] +
' ' +
postEmojiSpace +
tributeFigure;
return demand;
}
function decorateWithEmojiOpts(demandOpts) {
if (isEmoji(demandOpts.topic)) {
demandOpts.isEmoji = true;
demandOpts.repeatNTimesToPluralize =
probable.roll(3) + probable.roll(3) + 2;
}
return demandOpts;
}
var demandsForSpecialTopics = {
confederate: 'CONFEDERATE FLAGS FOR THE CONFEDERATE FLAG FIRE',
confederacy:
'CONFEDERACIES FOR THE DOG-WHISTLING WHITE SUPREMACIST HUMAN SHITPILE'
};
function isSpecialTopic(topic) {
return topic in demandsForSpecialTopics;
}
function makeDemandForSpecialTopic(opts) {
return demandsForSpecialTopics[opts.topic];
}
module.exports = {
makeDemandForTopic: makeDemandForTopic,
decorateWithEmojiOpts: decorateWithEmojiOpts
};