UNPKG

yoastseo

Version:

Yoast client-side content analysis

29 lines (27 loc) 1.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = _default; /** * @typedef {import("../../../parse/structure").Node} Node * @typedef {import("../../../parse/structure/Sentence").default} Sentence */ /** * Gets all the sentences from paragraph and heading nodes. * These two node types are the nodes that should contain sentences for the analysis. * * @param {Node} tree The tree to get the sentences from. * @param {boolean} [setParentNode=false] Whether to set the parent node reference on the sentences. * * @returns {Sentence[]} The array of sentences retrieved from paragraph and heading nodes plus sourceCodeLocation of the parent node. */ function _default(tree, setParentNode = false) { // Get all nodes that have a sentence property which is not an empty array. const nodesWithSentences = tree.findAll(treeNode => !!treeNode.sentences); return nodesWithSentences.flatMap(node => node.sentences.map(sentence => { sentence.setParentAttributes(node, tree, setParentNode); return sentence; })); } //# sourceMappingURL=getSentencesFromTree.js.map