Gathering detailed insights and metrics for unist-util-remove
Gathering detailed insights and metrics for unist-util-remove
Gathering detailed insights and metrics for unist-util-remove
Gathering detailed insights and metrics for unist-util-remove
unist-util-remove-position
unist utility to remove positions from a tree
unist-util-visit-parents
unist utility to recursively walk over nodes, with ancestral information
unist-util-is
unist utility to check if a node passes a test
unist-util-stringify-position
unist utility to serialize a node, position, or point as a human readable location
npm install unist-util-remove
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
22 Stars
96 Commits
2 Forks
9 Watching
1 Branches
12 Contributors
Updated on 02 Nov 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-5.8%
318,634
Compared to previous day
Last week
1.9%
1,782,955
Compared to previous week
Last month
5.4%
7,710,750
Compared to previous month
Last year
-43.2%
105,953,249
Compared to previous year
unist utility to remove all nodes that pass a test from the tree.
This is a small utility that helps you clean a tree by removing some stuff.
You can use this utility to remove things from a tree.
This utility is very similar to unist-util-filter
, which
creates a new tree.
Modifying a tree like this utility unist-util-remove
does is much faster on
larger documents though.
You can also walk the tree with unist-util-visit
to remove
nodes.
To create trees, use unist-builder
.
This package is ESM only. In Node.js (version 16+), install with npm:
1npm install unist-util-remove
In Deno with esm.sh
:
1import {remove} from 'https://esm.sh/unist-util-remove@4'
In browsers with esm.sh
:
1<script type="module"> 2 import {remove} from 'https://esm.sh/unist-util-remove@4?bundle' 3</script>
1import {u} from 'unist-builder' 2import {remove} from 'unist-util-remove' 3 4const tree = u('root', [ 5 u('leaf', '1'), 6 u('parent', [ 7 u('leaf', '2'), 8 u('parent', [u('leaf', '3'), u('other', '4')]), 9 u('parent', [u('leaf', '5')]) 10 ]), 11 u('leaf', '6') 12]) 13 14// Remove all nodes of type `leaf`. 15remove(tree, 'leaf') 16 17console.dir(tree, {depth: undefined})
Yields:
1{ 2 type: 'root', 3 children: [ 4 { 5 type: 'parent', 6 children: [{type: 'parent', children: [{type: 'other', value: '4'}]}] 7 } 8 ] 9}
👉 Note: the parent of leaf
5
is also removed,options.cascade
can change that.
This package exports the identifier remove
.
There is no default export.
remove(tree[, options], test)
Change the given tree
by removing all nodes that pass test
.
tree
itself is never tested.
The tree is walked in preorder (NLR), visiting the node itself, then its
head, etc.
tree
(Node
)
— tree to changeoptions
(Options
, optional)
— configurationtest
(Test
, optional)
— unist-util-is
compatible testNothing (undefined
).
Options
Configuration (TypeScript type).
cascade
(boolean
, default: true
)
— whether to drop parent nodes if they had children, but all their children
were filtered outThis package is fully typed with TypeScript.
It exports the additional type Options
.
Projects maintained by the unified collective are compatible with maintained versions of Node.js.
When we cut a new major release, we drop support for unmaintained versions of
Node.
This means we try to keep the current release line, unist-util-remove@^4
,
compatible with Node.js 16.
unist-util-filter
— create a new tree with all nodes that pass the given functionunist-util-flatmap
— create a new tree by expanding a node into manyunist-util-map
— create a new tree by mapping nodesunist-util-select
— select nodes with CSS-like selectorsunist-util-visit
— walk the treeunist-builder
— create treesSee contributing.md
in syntax-tree/.github
for
ways to get started.
See support.md
for ways to get help.
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
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More