unist-util-find
Advanced tools
+1
-1
@@ -19,2 +19,2 @@ var remark = require('remark') | ||
| }) | ||
| .process('Some _emphasis_, **strongness**, and `code`.') | ||
| .processSync('Some _emphasis_, **strongness**, and `code`.') |
+3
-3
| { | ||
| "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" | ||
| } | ||
| } |
+2
-2
@@ -1,2 +0,2 @@ | ||
| # unist-find [](https://travis-ci.org/blahah/unist-util-find) | ||
| # unist-util-find [](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 @@ ``` |
+30
-34
@@ -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() | ||
| }) | ||
| } | ||
| }) |
Sorry, the diff of this file is not supported yet
2
-33.33%6451
-17.81%3
50%7
-12.5%83
-4.6%- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed