src/index.js
/**
     * Sets a condition that when met the generator will stop adding any more words to the sentence.
     * If condition is a function - will generate words until the function returns true. This function gets passed the generated sentence so far
     * If condition is a string - will generate words until the last word matches this string
     * If condition is a number - will generate words until the sentence is this many words long
     *
     * @param {conditionFn|string|number} condition a condition that when met the generator
     *                                    will stop adding any more words to the sentence
     * @return {Markovski}
     */
Sets a condition that when met the generator will stop adding any more words to the sentence.
If condition is a function - will generate words until the function returns true. This function gets passed the generated sentence so far
If condition is a string - will generate words until the last word matches this string
If condition is a number - will generate words until the sentence is this many words long

@param {conditionFn|string|number} condition a condition that when met the generator
will stop adding any more words to the sentence
@return {Markovski}
Sets a condition that when met the generator will stop adding any more words to the sentence . If condition is a function - will generate words until the function returns true . This function gets passed the generated sentence so far If condition is a string - will generate words until the last word matches this string If condition is a number - will generate words until the sentence is this many words long @param { conditionFn|string|number } condition a condition that when met the generator will stop adding any more words to the sentence @return { Markovski }
endWhen(condition) {
        if (typeof condition === "function") {
            this._shouldEnd = sentence => condition(sentence);
        } else if (typeof condition === "string") {
            this._shouldEnd = sentence => {
                const lastWord = sentence.slice(-1)[0];
                return condition === lastWord;
            };
        } else if (typeof condition === "number" || condition === undefined) {
            condition = condition || Infinity;
            this._shouldEnd = sentence => sentence.length >= condition;
        } else {
            throw new Error("Argument must be a function, a string, or a number");
        }
        return this;
    }
endWhen ( condition ) { if ( typeof condition === "function" ) { this . _shouldEnd = sentence => condition ( sentence ) ; } else if ( typeof condition === "string" ) { this . _shouldEnd = sentence => { const lastWord = sentence . slice ( - 1 ) [ 0 ] ; return condition === lastWord ; } ; } else if ( typeof condition === "number" || condition === undefined ) { condition = condition || Infinity ; this . _shouldEnd = sentence => sentence . length >= condition ; } else { throw new Error ( "Argument must be a function, a string, or a number" ) ; } return this ; }
Sets a condition that when met the generator will stop adding any more words to the sentence.
Sets a condition that when met the generator will stop adding any more words to the sentence .