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.1 to 1.0.2

2

example.js

@@ -19,2 +19,2 @@ var remark = require('remark')

})
.process('Some _emphasis_, **strongness**, and `code`.')
.processSync('Some _emphasis_, **strongness**, and `code`.')
{
"name": "unist-util-find",
"version": "1.0.1",
"version": "1.0.2",
"description": "Unist node finder utility. Useful for working with remark, rehype and retext.",

@@ -24,3 +24,4 @@ "repository": "https://github.com/blahah/unist-util-find",

"devDependencies": {
"standard": "^7.1.2",
"remark": "^7.0.0",
"standard": "^8.0.0",
"tape": "^4.6.0"

@@ -30,5 +31,4 @@ },

"lodash.iteratee": "^4.5.0",
"remark": "^5.0.1",
"unist-util-visit": "^1.1.0"
}
}

@@ -1,2 +0,2 @@

# unist-find [![Travis](https://img.shields.io/travis/blahah/unist-util-find.svg)](https://travis-ci.org/blahah/unist-util-find)
# unist-util-find [![Travis](https://img.shields.io/travis/blahah/unist-util-find.svg)](https://travis-ci.org/blahah/unist-util-find)

@@ -34,3 +34,3 @@ [Unist](https://github.com/wooorm/unist) node finder utility. Useful for working with [remark](https://github.com/wooorm/remark), [rehype](https://github.com/wooorm/rehype) and [retext](https://github.com/wooorm/retext).

})
.process('Some _emphasis_, **strongness**, and `code`.')
.processSync('Some _emphasis_, **strongness**, and `code`.')

@@ -37,0 +37,0 @@ ```

@@ -5,50 +5,46 @@ var test = require('tape')

remark()
.use(function () { return run })
.process('Some _emphasis_, **strongness**, and `code`.')
test('unist-find', function (t) {
var tree = remark().parse('Some _emphasis_, **strongness**, and `code`.')
function run (tree) {
test('unist-find', function (t) {
t.throws(function () {
find()
}, 'should fail without tree')
t.throws(function () {
find()
}, 'should fail without tree')
t.throws(function () {
find(tree)
}, 'should fail without condition')
t.throws(function () {
find(tree)
}, 'should fail without condition')
t.test('should find with string condition', function (st) {
var result = find(tree, 'value')
t.test('should find with string condition', function (st) {
var result = find(tree, 'value')
st.equal(result, tree.children[0].children[0])
st.equal(result, tree.children[0].children[0])
st.end()
})
st.end()
})
t.test('should find with object condition', function (st) {
var result = find(tree, { type: 'emphasis' })
t.test('should find with object condition', function (st) {
var result = find(tree, { type: 'emphasis' })
st.equal(result, tree.children[0].children[1])
st.equal(result, tree.children[0].children[1])
st.end()
st.end()
})
t.test('should find with function condition', function (st) {
var result = find(tree, function (node) {
return node.type === 'inlineCode'
})
t.test('should find with function condition', function (st) {
var result = find(tree, function (node) {
return node.type === 'inlineCode'
})
st.equal(result, tree.children[0].children[5])
st.equal(result, tree.children[0].children[5])
st.end()
})
st.end()
})
t.test('should return undefined if no matches', function (st) {
var result = find(tree, 'nope, nope, nope')
t.test('should return undefined if no matches', function (st) {
var result = find(tree, 'nope, nope, nope')
st.equal(result, undefined)
st.equal(result, undefined)
st.end()
})
st.end()
})
}
})
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