UNPKG

@geekbears/gb-mongoose-keywords-plugin

Version:
22 lines 852 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.extractKeywordsFromString = void 0; var 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 */ var extractKeywordsFromString = function (value, omit) { return value .toString() .toLowerCase() .replace(/[^\w\d ]/g, '') // TODO: Find out if this omits unicode chars .split(' ') .filter(function (word) { return !(0, lodash_1.isEmpty)(word); }) .filter(function (word) { return !omit.includes(word); }); }; exports.extractKeywordsFromString = extractKeywordsFromString; //# sourceMappingURL=extract-keywords-from-string.helper.js.map