extractWords.js 374 B

12345678910
  1. const removeNonAlphaChars = require('./removeNonAlphaChars');
  2. const extractWords = (source, reservedWords, wordLength) =>
  3. removeNonAlphaChars(source)
  4. .split(' ')
  5. .map((word) => word.trim())
  6. .filter((word) => Object.keys(reservedWords).indexOf(word) !== -1 || (word.length >= wordLength && !/^\d+$/i.test(word)));
  7. module.exports = extractWords;