Socket
Socket
Sign inDemoInstall

unist-util-find

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unist-util-find - npm Package Compare versions

Comparing version 1.0.2 to 1.0.4

index.d.ts

37

index.js

@@ -7,6 +7,13 @@ /**

* @fileoverview Unist node finder
*
* @typedef {import('unist').Node} Node
*
* @typedef {string} TestStr
* Finds first node with a truthy property matching string.
* @typedef {Object.<string, unknown>} TestObj
* Finds first node that has matching values for all properties of object.
* @typedef {<V extends Node>(node: V) => boolean} TestFn
* Finds first node for which function returns true when passed node as argument.
*/
'use strict'
var visit = require('unist-util-visit')

@@ -16,13 +23,18 @@ var iteratee = require('lodash.iteratee')

/**
* Find
* Unist node finder utility.
*
* @param {Node} tree - Root node
* @param {string|object|function} [condition] - Condition to match node.
* @param tree
* Node to search.
* @param condition
* Condition used to test each node.
* @returns
* The first node that matches condition, or undefined if no node matches.
* @type {<V extends Node>(tree: Node, condition: TestStr | TestObj | TestFn) => V | undefined}
*/
function find (tree, condition) {
if (!tree) throw new Error('unist-find requires a tree to search')
if (!condition) throw new Error('unist-find requires a condition')
module.exports = function find (tree, condition) {
if (!tree) throw new Error('unist-util-find requires a tree to search')
if (!condition) throw new Error('unist-util-find requires a condition')
var predicate = iteratee(condition)
var result
const predicate = iteratee(condition)
let result

@@ -38,6 +50,1 @@ visit(tree, function (node) {

}
/*
* Expose.
*/
module.exports = find
{
"name": "unist-util-find",
"version": "1.0.2",
"version": "1.0.4",
"description": "Unist node finder utility. Useful for working with remark, rehype and retext.",
"repository": "https://github.com/blahah/unist-util-find",
"main": "index.js",
"types": "index.d.ts",
"files": [
"index.d.ts",
"index.js"
],
"sideEffects": false,
"scripts": {
"test": "standard && node test.js"
"prepack": "npm run build",
"test": "standard && node test.js",
"build": "tsc"
},
"type": "commonjs",
"keywords": [

@@ -24,10 +33,13 @@ "unist",

"devDependencies": {
"remark": "^7.0.0",
"@types/lodash.iteratee": "^4.7.7",
"@types/unist": "^2.0.6",
"remark": "^13.0.0",
"standard": "^8.0.0",
"tape": "^4.6.0"
"tape": "^5.3.1",
"typescript": "^4.6.4"
},
"dependencies": {
"lodash.iteratee": "^4.5.0",
"unist-util-visit": "^1.1.0"
"lodash.iteratee": "^4.7.0",
"unist-util-visit": "^2.0.0"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc