Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
unist-util-find
Advanced tools
Unist node finder utility. Useful for working with remark, rehype and retext.
Unist node finder utility. Useful for working with remark, rehype and retext.
npm install --save unist-util-find
var remark = require('remark')
var find = require('unist-util-find')
remark()
.use(function () {
return function (tree) {
// string condition
console.log(find(tree, 'value'))
// object condition
console.log(find(tree, { value: 'emphasis' }))
// function condition
console.log(find(tree, function (node) {
return node.type === 'inlineCode'
}))
}
})
.processSync('Some _emphasis_, **strongness**, and `code`.')
Result:
// string condition: 'value'
{ type: 'text',
value: 'Some ',
position:
Position {
start: { line: 1, column: 1, offset: 0 },
end: { line: 1, column: 6, offset: 5 },
indent: [] } }
// object condition: { value: 'emphasis' }
{ type: 'text',
value: 'emphasis',
position:
Position {
start: { line: 1, column: 7, offset: 6 },
end: { line: 1, column: 15, offset: 14 },
indent: [] } }
// function condition: function (node) { return node.type === 'inlineCode' }
{ type: 'inlineCode',
value: 'code',
position:
Position {
start: { line: 1, column: 38, offset: 37 },
end: { line: 1, column: 44, offset: 43 },
indent: [] } }
find(node, condition)
Return the first node that matches condition
, or undefined
if no node matches.
node
(Node
) - Node to searchcondition
(string
, object
or function
) - Condition used to test each node. Behaviour depends on the type of the condition:
string
finds first node with a truthy property matching string
object
finds first node that has matching values for all properties of object
function
finds first node for which function
returns true when passed node
as argumentMIT
FAQs
unist utility to find a node
The npm package unist-util-find receives a total of 38,732 weekly downloads. As such, unist-util-find popularity was classified as popular.
We found that unist-util-find demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.