- }, this);
-
- resolve();
- }.bind(this));
- },
-
- _getVerb : function _getVerb() {
- var index;
- index = Math.floor(Math.random()*this.verbs.length);
- return Promise.resolve(this.verbs[index]);
- },
-
- _conjugateVerb : function _conjugateVerb(verb) {
- return new Promise(function (resolve, reject) {
- var tries;
-
- tries = 0;
-
- var attemptConjugation = function attemptConjugation(verb, tries) {
- if (tries > this._maxTries) {
- return reject(new Error("Couldn't find a proper verb"));
- };
-
- this._conjugator.conjugate(verb)
- .then(function (conjugatedVerb) {
- resolve(conjugatedVerb);
- })
- .catch(function (err) {
- this._getVerb().then(function (verb) {
- attemptConjugation.bind(this)(verb, tries + 1);
- }.bind(this))
- }.bind(this));
- };
-
- setTimeout(attemptConjugation.bind(this, verb, 0), 0);
- }.bind(this));
- },
-
- _getNoun : function _getNoun() {
- var index, noun;
- index = Math.floor(Math.random()*this.nouns.length);
- return Promise.resolve(this.nouns[index].toLowerCase());
- },
-
- _generateInsult : function _generateInsult(verb, noun) {
- return Promise.resolve(verb + this._pluralize(noun));
- },
-
- // Super dumb pluralizer
- _pluralize : function _pluralize(noun) {
- var lastLetter;
-
- lastLetter = noun[noun.length - 1];
-
- if (lastLetter === "s") {
- return noun;
- }
-
- if (["a","e","i","o","u"].indexOf(lastLetter) >= 0) {
- return noun + "s"
- }
-
- return noun + "es";
+ });
+
+ console.debug(`Nouns: ${nouns.size}, Verbs: ${verbs.size}`);
+
+ resolve({
+ verbs: [...verbs],
+ nouns: [...nouns]
+ });
+ });
+ });
+ },
+
+ // Gets a conjugated verb
+
+ async getVerb() {
+
+ const verbs = await internals.getWordList('verbs');
+ const verb = verbs[Math.floor(Math.random()*verbs.length)];
+ return await Conjugator.conjugate(verb);
+ },
+
+ // Gets a pluralized noun
+
+ async getNoun() {
+
+ const nouns = await internals.getWordList('nouns');
+ const noun = nouns[Math.floor(Math.random()*nouns.length)];
+ return internals.pluralize(noun);
+ },
+
+ // Pluralizes a word
+
+ pluralize(noun) {
+
+ const lastLetter = noun[noun.length - 1];
+
+ if (lastLetter === 's') {
+ return noun;