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
mdast-squeeze-paragraphs
mdast utility to remove empty paragraphs from a tree
typed-unist-util-remove-position
mdast-util-tight-comments
mdast-util-to-markdown extension to selectively remove newlines around mdast comment nodes
npm install unist-util-remove
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
23 Stars
96 Commits
2 Forks
8 Watchers
1 Branches
12 Contributors
Updated on May 02, 2025
Latest Version
4.0.0
Package Id
unist-util-remove@4.0.0
Unpacked Size
12.64 kB
Size
4.71 kB
File Count
7
NPM Version
9.7.2
Node Version
20.0.0
Published on
Jul 07, 2023
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
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 dangerous workflow patterns detected
Reason
no binaries found in the repo
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
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
detected GitHub workflow tokens with excessive permissions
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 2025-06-30
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