Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
unist-util-flat-filter
Advanced tools
[**unist**][unist] utility to create a new tree with all nodes that pass the given test.
[unist][unist] utility to create a new tree with all nodes that pass the given test.
[npm][]:
npm install unist-util-flat-filter
var u = require('unist-builder')
var flatFilter = require('unist-util-flat-filter')
var tree = u('root', [
u('leaf', '1'),
u('node', [u('leaf', '2'), u('node', [u('leaf', '3')])]),
u('leaf', '4')
])
var newTree = flatFilter(tree, node => node.type === 'leaf')
console.dir(newTree, {depth: null})
Yields:
{
type: 'root',
children: [
{ type: 'leaf', value: '1' },
{ type: 'leaf', value: '2' },
{ type: 'leaf', value: '3' },
{ type: 'leaf', value: '4' }
]
}
filter(tree[, test])
Create a new [tree][] consisting of copies of all nodes that pass test
.
The tree is walked in [order][], visiting the parent, then the children nodes node itself, etc.
tree
([Node?
][node])
— [Tree][] to filtertest
([Test
][is], optional) — [is
][is]-compatible test (such as a
[type][])[Node?
][node] — New filtered [tree][].
null
is returned if tree
itself didn’t pass the test, or is cascaded away.
FAQs
Create a new Unist tree by filtering with the provided function and getting all of the returned results in a flat list, not including parent nodes
The npm package unist-util-flat-filter receives a total of 745 weekly downloads. As such, unist-util-flat-filter popularity was classified as not popular.
We found that unist-util-flat-filter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.