count-words-repetitions
Version:
Count the number of repetitions of each word quickly and easily!
17 lines (16 loc) • 911 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.textIsEmpty = exports.isNumber = exports.incrementItemRepeats = exports.getIndexByItem = exports.findByText = exports.splitBySpace = void 0;
const lodash_1 = require("lodash");
const splitBySpace = (item) => (0, lodash_1.split)(item, " ");
exports.splitBySpace = splitBySpace;
const findByText = (item, items) => (0, lodash_1.find)(items, (x) => x.text == item) !== undefined;
exports.findByText = findByText;
const getIndexByItem = (item, items) => (0, lodash_1.findIndex)(items, (x) => x.text == item);
exports.getIndexByItem = getIndexByItem;
const incrementItemRepeats = (item) => item.repeats++;
exports.incrementItemRepeats = incrementItemRepeats;
const isNumber = (item) => isNaN(parseInt(item));
exports.isNumber = isNumber;
const textIsEmpty = (item) => item == "";
exports.textIsEmpty = textIsEmpty;