unist utility to modify the given tree by removing all nodes that pass the given test.
npm install unist-util-remove
var u =var remove =var tree =// Remove all nodes of type `leaf`.consoledirtree depth: null
Yields: (note the parent of
5 is also removed, due to
type: 'root'children:type: 'node'children:type: 'node' children: type: 'other' value: '4'
remove(tree[, options][, test])
Node?) — Tree to filter
true) — Whether to drop parent nodes if they had children, but all their children were filtered out
Test, optional) —
is-compatible test (such as a type)
Node? — The given
tree with nodes for which
test passed removed.
null is returned if
tree itself didn’t pass the test, or is cascaded away.
unist-util-filter— Create a new tree with all nodes that pass the given function
unist-util-flatmap— Create a new tree by expanding a node into many
unist-util-map— Create a new tree by mapping nodes
unist-util-select— Select nodes with CSS-like selectors
unist-util-visit— Recursively walk over nodes
unist-builder— Creating trees
This project has a Code of Conduct. By interacting with this repository, organisation, or community you agree to abide by its terms.
MIT © Eugene Sharygin