UNPKG

@geekbears/gb-mongoose-keywords-plugin

Version:
22 lines 810 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.extractKeywordsFromString = void 0; const lodash_1 = require("lodash"); /** * Generate a set of keywords from a source string * * @param value the source string * @param omit a set of words to be omitted from the resulting keywords * @returns the resulting set of keywords */ const extractKeywordsFromString = (value, omit) => { return value .toString() .toLowerCase() .replace(/[^\w\d ]/g, '') // TODO: Find out if this omits unicode chars .split(' ') .filter(word => !(0, lodash_1.isEmpty)(word)) .filter(word => !omit.includes(word)); }; exports.extractKeywordsFromString = extractKeywordsFromString; //# sourceMappingURL=extract-keywords-from-string.helper.js.map