yoastseo
Version:
Yoast client-side content analysis
29 lines (27 loc) • 1.03 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var _lodash = require("lodash");
/**
* Checks whether a given word is followed by any word from a given list.
*
* @param {Array} followingWords The array of objects with matches and indices.
* @param {Object} match The object with the match and index to test the following words for.
*
* @returns {boolean} Returns true if the match is followed by a given word, otherwise returns false.
*/
function _default(followingWords, match) {
if ((0, _lodash.isEmpty)(followingWords)) {
return false;
}
// The followingWordIndices include the preceding space.
const wordAfterMatchIndex = match.index + match.match.length;
const followingWordsIndices = [];
(0, _lodash.forEach)(followingWords, function (followingWord) {
followingWordsIndices.push(followingWord.index);
});
return (0, _lodash.includes)(followingWordsIndices, wordAfterMatchIndex);
}
//# sourceMappingURL=followsIndex.js.map