UNPKG

compromise

Version:
20 lines (19 loc) 522 B
const getWords = function (net) { return Object.keys(net.hooks).filter(w => !w.startsWith('#') && !w.startsWith('%')) } const maybeMatch = function (doc, net) { // must have *atleast* one of these words const words = getWords(net) if (words.length === 0) { return doc } if (!doc._cache) { doc.cache() } const cache = doc._cache // return sentences that have one of our needed words return doc.filter((_m, i) => { return words.some(str => cache[i].has(str)) }) } export default maybeMatch