diff --git a/parse-rfd/parser/dist/index.js b/parse-rfd/parser/dist/index.js index b43ad07..9c7b1c1 100644 --- a/parse-rfd/parser/dist/index.js +++ b/parse-rfd/parser/dist/index.js @@ -49765,7 +49765,7 @@ function getMergeFunction(key, options) { function getEnumerableOwnPropertySymbols(target) { return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(target).filter(function(symbol) { - return target.propertyIsEnumerable(symbol) + return Object.propertyIsEnumerable.call(target, symbol) }) : [] } @@ -51004,7 +51004,7 @@ function getRssFeed(feedRoot) { addConditionally(entry, "title", "title", children); addConditionally(entry, "link", "link", children); addConditionally(entry, "description", "description", children); - var pubDate = fetch("pubDate", children); + var pubDate = fetch("pubDate", children) || fetch("dc:date", children); if (pubDate) entry.pubDate = new Date(pubDate); return entry; @@ -51121,11 +51121,12 @@ Object.defineProperty(exports, "__esModule", ({ value: true })); exports.uniqueSort = exports.compareDocumentPosition = exports.DocumentPosition = exports.removeSubsets = void 0; var domhandler_1 = __nccwpck_require__(4038); /** - * Given an array of nodes, remove any member that is contained by another. + * Given an array of nodes, remove any member that is contained by another + * member. * * @category Helpers * @param nodes Nodes to filter. - * @returns Remaining nodes that aren't subtrees of each other. + * @returns Remaining nodes that aren't contained by other nodes. */ function removeSubsets(nodes) { var idx = nodes.length; @@ -51167,8 +51168,8 @@ var DocumentPosition; DocumentPosition[DocumentPosition["CONTAINED_BY"] = 16] = "CONTAINED_BY"; })(DocumentPosition = exports.DocumentPosition || (exports.DocumentPosition = {})); /** - * Compare the position of one node against another node in any other document. - * The return value is a bitmask with the values from {@link DocumentPosition}. + * Compare the position of one node against another node in any other document, + * returning a bitmask with the values from {@link DocumentPosition}. * * Document order: * > There is an ordering, document order, defined on all the nodes in the @@ -51233,9 +51234,9 @@ function compareDocumentPosition(nodeA, nodeB) { } exports.compareDocumentPosition = compareDocumentPosition; /** - * Sort an array of nodes based on their relative position in the document and - * remove any duplicate nodes. If the array contains nodes that do not belong to - * the same document, sort order is unspecified. + * Sort an array of nodes based on their relative position in the document, + * removing any duplicate nodes. If the array contains nodes that do not belong + * to the same document, sort order is unspecified. * * @category Helpers * @param nodes Array of DOM nodes. @@ -51309,6 +51310,9 @@ Object.defineProperty(exports, "__esModule", ({ value: true })); exports.getElementsByTagType = exports.getElementsByTagName = exports.getElementById = exports.getElements = exports.testElement = void 0; var domhandler_1 = __nccwpck_require__(4038); var querying_js_1 = __nccwpck_require__(9908); +/** + * A map of functions to check nodes against. + */ var Checks = { tag_name: function (name) { if (typeof name === "function") { @@ -51333,6 +51337,9 @@ var Checks = { }, }; /** + * Returns a function to check whether a node has an attribute with a particular + * value. + * * @param attrib Attribute to check. * @param value Attribute value to look for. * @returns A function to check whether the a node has an attribute with a @@ -51345,6 +51352,9 @@ function getAttribCheck(attrib, value) { return function (elem) { return (0, domhandler_1.isTag)(elem) && elem.attribs[attrib] === value; }; } /** + * Returns a function that returns `true` if either of the input functions + * returns `true` for a node. + * * @param a First function to combine. * @param b Second function to combine. * @returns A function taking a node and returning `true` if either of the input @@ -51354,9 +51364,12 @@ function combineFuncs(a, b) { return function (elem) { return a(elem) || b(elem); }; } /** + * Returns a function that executes all checks in `options` and returns `true` + * if any of them match a node. + * * @param options An object describing nodes to look for. - * @returns A function executing all checks in `options` and returning `true` if - * any of them match a node. + * @returns A function that executes all checks in `options` and returns `true` + * if any of them match a node. */ function compileTest(options) { var funcs = Object.keys(options).map(function (key) { @@ -51368,6 +51381,8 @@ function compileTest(options) { return funcs.length === 0 ? null : funcs.reduce(combineFuncs); } /** + * Checks whether a node matches the description in `options`. + * * @category Legacy Query Functions * @param options An object describing nodes to look for. * @param node The element to test. @@ -51379,6 +51394,8 @@ function testElement(options, node) { } exports.testElement = testElement; /** + * Returns all nodes that match `options`. + * * @category Legacy Query Functions * @param options An object describing nodes to look for. * @param nodes Nodes to search through. @@ -51393,6 +51410,8 @@ function getElements(options, nodes, recurse, limit) { } exports.getElements = getElements; /** + * Returns the node with the supplied ID. + * * @category Legacy Query Functions * @param id The unique ID attribute value to look for. * @param nodes Nodes to search through. @@ -51407,6 +51426,8 @@ function getElementById(id, nodes, recurse) { } exports.getElementById = getElementById; /** + * Returns all nodes with the supplied `tagName`. + * * @category Legacy Query Functions * @param tagName Tag name to search for. * @param nodes Nodes to search through. @@ -51421,6 +51442,8 @@ function getElementsByTagName(tagName, nodes, recurse, limit) { } exports.getElementsByTagName = getElementsByTagName; /** + * Returns all nodes with the supplied `type`. + * * @category Legacy Query Functions * @param type Element type to look for. * @param nodes Nodes to search through. @@ -51458,8 +51481,14 @@ function removeElement(elem) { elem.next.prev = elem.prev; if (elem.parent) { var childs = elem.parent.children; - childs.splice(childs.lastIndexOf(elem), 1); + var childsIndex = childs.lastIndexOf(elem); + if (childsIndex >= 0) { + childs.splice(childsIndex, 1); + } } + elem.next = null; + elem.prev = null; + elem.parent = null; } exports.removeElement = removeElement; /** @@ -51490,15 +51519,15 @@ exports.replaceElement = replaceElement; * Append a child to an element. * * @category Manipulation - * @param elem The element to append to. + * @param parent The element to append to. * @param child The element to be added as a child. */ -function appendChild(elem, child) { +function appendChild(parent, child) { removeElement(child); child.next = null; - child.parent = elem; - if (elem.children.push(child) > 1) { - var sibling = elem.children[elem.children.length - 2]; + child.parent = parent; + if (parent.children.push(child) > 1) { + var sibling = parent.children[parent.children.length - 2]; sibling.next = child; child.prev = sibling; } @@ -51538,15 +51567,15 @@ exports.append = append; * Prepend a child to an element. * * @category Manipulation - * @param elem The element to prepend before. + * @param parent The element to prepend before. * @param child The element to be added as a child. */ -function prependChild(elem, child) { +function prependChild(parent, child) { removeElement(child); - child.parent = elem; + child.parent = parent; child.prev = null; - if (elem.children.unshift(child) !== 1) { - var sibling = elem.children[1]; + if (parent.children.unshift(child) !== 1) { + var sibling = parent.children[1]; sibling.prev = child; child.next = sibling; } @@ -51591,7 +51620,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true })); exports.findAll = exports.existsOne = exports.findOne = exports.findOneChild = exports.find = exports.filter = void 0; var domhandler_1 = __nccwpck_require__(4038); /** - * Search a node and its children for nodes passing a test function. + * Search a node and its children for nodes passing a test function. If `node` is not an array, it will be wrapped in one. * * @category Querying * @param test Function to test nodes on. @@ -51603,13 +51632,11 @@ var domhandler_1 = __nccwpck_require__(4038); function filter(test, node, recurse, limit) { if (recurse === void 0) { recurse = true; } if (limit === void 0) { limit = Infinity; } - if (!Array.isArray(node)) - node = [node]; - return find(test, node, recurse, limit); + return find(test, Array.isArray(node) ? node : [node], recurse, limit); } exports.filter = filter; /** - * Search an array of node and its children for nodes passing a test function. + * Search an array of nodes and their children for nodes passing a test function. * * @category Querying * @param test Function to test nodes on. @@ -51620,26 +51647,42 @@ exports.filter = filter; */ function find(test, nodes, recurse, limit) { var result = []; - for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { - var elem = nodes_1[_i]; + /** Stack of the arrays we are looking at. */ + var nodeStack = [nodes]; + /** Stack of the indices within the arrays. */ + var indexStack = [0]; + for (;;) { + // First, check if the current array has any more elements to look at. + if (indexStack[0] >= nodeStack[0].length) { + // If we have no more arrays to look at, we are done. + if (indexStack.length === 1) { + return result; + } + // Otherwise, remove the current array from the stack. + nodeStack.shift(); + indexStack.shift(); + // Loop back to the start to continue with the next array. + continue; + } + var elem = nodeStack[0][indexStack[0]++]; if (test(elem)) { result.push(elem); if (--limit <= 0) - break; + return result; } if (recurse && (0, domhandler_1.hasChildren)(elem) && elem.children.length > 0) { - var children = find(test, elem.children, recurse, limit); - result.push.apply(result, children); - limit -= children.length; - if (limit <= 0) - break; + /* + * Add the children to the stack. We are depth-first, so this is + * the next array we look at. + */ + indexStack.unshift(0); + nodeStack.unshift(elem.children); } } - return result; } exports.find = find; /** - * Finds the first element inside of an array that matches a test function. + * Finds the first element inside of an array that matches a test function. This is an alias for `Array.prototype.find`. * * @category Querying * @param test Function to test nodes on. @@ -51656,29 +51699,31 @@ exports.findOneChild = findOneChild; * * @category Querying * @param test Function to test nodes on. - * @param nodes Array of nodes to search. + * @param nodes Node or array of nodes to search. * @param recurse Also consider child nodes. - * @returns The first child node that passes `test`. + * @returns The first node that passes `test`. */ function findOne(test, nodes, recurse) { if (recurse === void 0) { recurse = true; } var elem = null; for (var i = 0; i < nodes.length && !elem; i++) { - var checked = nodes[i]; - if (!(0, domhandler_1.isTag)(checked)) { + var node = nodes[i]; + if (!(0, domhandler_1.isTag)(node)) { continue; } - else if (test(checked)) { - elem = checked; + else if (test(node)) { + elem = node; } - else if (recurse && checked.children.length > 0) { - elem = findOne(test, checked.children, true); + else if (recurse && node.children.length > 0) { + elem = findOne(test, node.children, true); } } return elem; } exports.findOne = findOne; /** + * Checks if a tree of nodes contains at least one node passing a test. + * * @category Querying * @param test Function to test nodes on. * @param nodes Array of nodes to search. @@ -51687,14 +51732,12 @@ exports.findOne = findOne; function existsOne(test, nodes) { return nodes.some(function (checked) { return (0, domhandler_1.isTag)(checked) && - (test(checked) || - (checked.children.length > 0 && - existsOne(test, checked.children))); + (test(checked) || existsOne(test, checked.children)); }); } exports.existsOne = existsOne; /** - * Search and array of nodes and its children for elements passing a test function. + * Search an array of nodes and their children for elements passing a test function. * * Same as `find`, but limited to elements and with less options, leading to reduced complexity. * @@ -51704,19 +51747,30 @@ exports.existsOne = existsOne; * @returns All nodes passing `test`. */ function findAll(test, nodes) { - var _a; var result = []; - var stack = nodes.filter(domhandler_1.isTag); - var elem; - while ((elem = stack.shift())) { - var children = (_a = elem.children) === null || _a === void 0 ? void 0 : _a.filter(domhandler_1.isTag); - if (children && children.length > 0) { - stack.unshift.apply(stack, children); + var nodeStack = [nodes]; + var indexStack = [0]; + for (;;) { + if (indexStack[0] >= nodeStack[0].length) { + if (nodeStack.length === 1) { + return result; + } + // Otherwise, remove the current array from the stack. + nodeStack.shift(); + indexStack.shift(); + // Loop back to the start to continue with the next array. + continue; } + var elem = nodeStack[0][indexStack[0]++]; + if (!(0, domhandler_1.isTag)(elem)) + continue; if (test(elem)) result.push(elem); + if (elem.children.length > 0) { + indexStack.unshift(0); + nodeStack.unshift(elem.children); + } } - return result; } exports.findAll = findAll; //# sourceMappingURL=querying.js.map @@ -51761,7 +51815,7 @@ function getInnerHTML(node, options) { } exports.getInnerHTML = getInnerHTML; /** - * Get a node's inner text. Same as `textContent`, but inserts newlines for `
` tags. + * Get a node's inner text. Same as `textContent`, but inserts newlines for `
` tags. Ignores comments. * * @category Stringify * @deprecated Use `textContent` instead. @@ -51781,7 +51835,7 @@ function getText(node) { } exports.getText = getText; /** - * Get a node's text content. + * Get a node's text content. Ignores comments. * * @category Stringify * @param node Node to get the text content of. @@ -51800,7 +51854,7 @@ function textContent(node) { } exports.textContent = textContent; /** - * Get a node's inner text. + * Get a node's inner text, ignoring `