UNPKG

orgast-util-visit-ids

Version:

orgast (uniorg) utility to visit all nodes with ids

19 lines 673 B
import { visitParents } from 'unist-util-visit-parents'; export function visitIds(tree, f) { // This issue does not seem fixed // 👀https://github.com/syntax-tree/unist-util-visit/issues/33 // @ts-ignore Incessantly deep type instantiation visitParents(tree, { type: 'node-property', key: 'ID' }, (property, ancestors) => { const id = property.value; let parent = ancestors.pop(); while (parent && parent.type !== 'section' && parent.type !== 'org-data') { parent = ancestors.pop(); } if (parent) { f(id, parent); } }); } //# sourceMappingURL=index.js.map