Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

unist-util-find

Package Overview
Dependencies
Maintainers
1
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.3

index.d.ts

39

index.js

@@ -7,21 +7,33 @@ /**

* @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'
import { visit } from 'unist-util-visit'
import iteratee from 'lodash.iteratee'
var visit = require('unist-util-visit')
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')
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,5 +50,2 @@ visit(tree, function (node) {

/*
* Expose.
*/
module.exports = find
export default find
{
"name": "unist-util-find",
"version": "1.0.2",
"version": "1.0.3",
"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"
"test": "standard && node test.js",
"build": "tsc",
"prepare": "npm run build",
"release": "release-it"
},
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},
"type": "module",
"keywords": [

@@ -24,10 +37,14 @@ "unist",

"devDependencies": {
"remark": "^7.0.0",
"standard": "^8.0.0",
"tape": "^4.6.0"
"@types/lodash.iteratee": "^4.7.7",
"@types/unist": "^2.0.6",
"release-it": "^15.11.0",
"remark": "^14.0.1",
"standard": "^16.0.4",
"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": "^4.1.0"
}
}
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc