unist-util-find-all-after
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -7,3 +7,2 @@ 'use strict' | ||
/* Find nodes after `index` in `parent` which pass `test`. */ | ||
function findAllAfter(parent, index, test) { | ||
@@ -10,0 +9,0 @@ var results = [] |
{ | ||
"name": "unist-util-find-all-after", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "Utility to find nodes after another node", | ||
@@ -16,5 +16,5 @@ "license": "MIT", | ||
"bugs": "https://github.com/syntax-tree/unist-util-find-all-after/issues", | ||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)", | ||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)", | ||
"contributors": [ | ||
"Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)" | ||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)" | ||
], | ||
@@ -26,15 +26,15 @@ "dependencies": { | ||
"browserify": "^16.0.0", | ||
"esmangle": "^1.0.0", | ||
"nyc": "^11.0.0", | ||
"prettier": "^1.12.1", | ||
"remark": "^9.0.0", | ||
"remark-cli": "^5.0.0", | ||
"remark-preset-wooorm": "^4.0.0", | ||
"tape": "^4.6.2", | ||
"xo": "^0.20.0" | ||
"nyc": "^14.0.0", | ||
"prettier": "^1.0.0", | ||
"remark": "^10.0.0", | ||
"remark-cli": "^6.0.0", | ||
"remark-preset-wooorm": "^5.0.0", | ||
"tape": "^4.0.0", | ||
"tinyify": "^2.5.0", | ||
"xo": "^0.24.0" | ||
}, | ||
"scripts": { | ||
"format": "remark . -qfo && prettier --write '**/*.js' && xo --fix", | ||
"build-bundle": "browserify index.js --no-builtins -s unistUtilFindAllAfter > unist-util-find-all-after.js", | ||
"build-mangle": "esmangle unist-util-find-all-after.js > unist-util-find-all-after.min.js", | ||
"format": "remark . -qfo && prettier --write \"**/*.js\" && xo --fix", | ||
"build-bundle": "browserify . -s unistUtilFindAllAfter -o unist-util-find-all-after.js", | ||
"build-mangle": "browserify . -s unistUtilFindAllAfter -p tinyify -o unist-util-find-all-after.min.js", | ||
"build": "npm run build-bundle && npm run build-mangle", | ||
@@ -63,5 +63,3 @@ "test-api": "node test", | ||
"rules": { | ||
"guard-for-in": "off", | ||
"no-var": "off", | ||
"prefer-arrow-callback": "off" | ||
"guard-for-in": "off" | ||
}, | ||
@@ -68,0 +66,0 @@ "ignore": [ |
@@ -1,5 +0,10 @@ | ||
# unist-util-find-all-after [![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov] | ||
# unist-util-find-all-after | ||
[**Unist**][unist] utility to find nodes after another node. | ||
[![Build][build-badge]][build] | ||
[![Coverage][coverage-badge]][coverage] | ||
[![Downloads][downloads-badge]][downloads] | ||
[![Size][size-badge]][size] | ||
[**unist**][unist] utility to find nodes after another node. | ||
## Installation | ||
@@ -16,9 +21,16 @@ | ||
```js | ||
var remark = require('remark') | ||
var u = require('unist-builder') | ||
var findAllAfter = require('unist-util-find-all-after') | ||
var tree = remark().parse('Some _emphasis_, **importance**, and `code`.') | ||
var paragraph = tree.children[0] | ||
var tree = u('tree', [ | ||
u('leaf', 'leaf 1'), | ||
u('node', [u('leaf', 'leaf 2'), u('leaf', 'leaf 3')]), | ||
u('leaf', 'leaf 4'), | ||
u('node', [u('leaf', 'leaf 5')]), | ||
u('leaf', 'leaf 6'), | ||
u('void'), | ||
u('leaf', 'leaf 7') | ||
]) | ||
console.log(findAllAfter(paragraph, 1, 'text')) | ||
console.log(findAllAfter(tree, 1, 'leaf')) | ||
``` | ||
@@ -29,5 +41,7 @@ | ||
```js | ||
[ { type: 'text', value: ', ' }, | ||
{ type: 'text', value: ', and ' }, | ||
{ type: 'text', value: '.' } ] | ||
[ | ||
{ type: 'leaf', value: 'leaf 4' }, | ||
{ type: 'leaf', value: 'leaf 6' }, | ||
{ type: 'leaf', value: 'leaf 7' } | ||
] | ||
``` | ||
@@ -44,6 +58,6 @@ | ||
* `parent` ([`Node`][node]) — Context node | ||
* `node` ([`Node`][node]) — Node in `parent` | ||
* `index` (`number`, optional) — Position of a `node` in `parent` | ||
* `test` (`Function`, `string`, or `Node`, optional) | ||
* `parent` ([`Node`][node]) — [Parent][] node | ||
* `node` ([`Node`][node]) — [Child][] of `parent` | ||
* `index` (`number`, optional) — [Index][] in `parent` | ||
* `test` (`Function`, `string`, `Object`, `Array`, optional) | ||
— See [`unist-util-is`][is] | ||
@@ -53,3 +67,3 @@ | ||
[`Array.<Node>`][node] — Child nodes of `parent` passing `test`. | ||
[`Array.<Node>`][node] — [Child][]ren of `parent` passing `test`. | ||
@@ -71,7 +85,9 @@ ## Related | ||
See [`contributing.md` in `syntax-tree/unist`][contributing] for ways to get | ||
See [`contributing.md` in `syntax-tree/.github`][contributing] for ways to get | ||
started. | ||
See [`support.md`][support] for ways to get help. | ||
This organisation has a [Code of Conduct][coc]. By interacting with this | ||
repository, organisation, or community you agree to abide by its terms. | ||
This project has a [Code of Conduct][coc]. | ||
By interacting with this repository, organisation, or community you agree to | ||
abide by its terms. | ||
@@ -84,15 +100,23 @@ ## License | ||
[travis-badge]: https://img.shields.io/travis/syntax-tree/unist-util-find-all-after.svg | ||
[build-badge]: https://img.shields.io/travis/syntax-tree/unist-util-find-all-after.svg | ||
[travis]: https://travis-ci.org/syntax-tree/unist-util-find-all-after | ||
[build]: https://travis-ci.org/syntax-tree/unist-util-find-all-after | ||
[codecov-badge]: https://img.shields.io/codecov/c/github/syntax-tree/unist-util-find-all-after.svg | ||
[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/unist-util-find-all-after.svg | ||
[codecov]: https://codecov.io/github/syntax-tree/unist-util-find-all-after | ||
[coverage]: https://codecov.io/github/syntax-tree/unist-util-find-all-after | ||
[downloads-badge]: https://img.shields.io/npm/dm/unist-util-find-all-after.svg | ||
[downloads]: https://www.npmjs.com/package/unist-util-find-all-after | ||
[size-badge]: https://img.shields.io/bundlephobia/minzip/unist-util-find-all-after.svg | ||
[size]: https://bundlephobia.com/result?p=unist-util-find-all-after | ||
[npm]: https://docs.npmjs.com/cli/install | ||
[license]: LICENSE | ||
[license]: license | ||
[author]: http://wooorm.com | ||
[author]: https://wooorm.com | ||
@@ -103,6 +127,14 @@ [unist]: https://github.com/syntax-tree/unist | ||
[parent]: https://github.com/syntax-tree/unist#parent-1 | ||
[child]: https://github.com/syntax-tree/unist#child | ||
[index]: https://github.com/syntax-tree/unist#index | ||
[is]: https://github.com/syntax-tree/unist-util-is | ||
[contributing]: https://github.com/syntax-tree/unist/blob/master/contributing.md | ||
[contributing]: https://github.com/syntax-tree/.github/blob/master/contributing.md | ||
[coc]: https://github.com/syntax-tree/unist/blob/master/code-of-conduct.md | ||
[support]: https://github.com/syntax-tree/.github/blob/master/support.md | ||
[coc]: https://github.com/syntax-tree/.github/blob/master/code-of-conduct.md |
41
test.js
@@ -70,25 +70,32 @@ 'use strict' | ||
assert.deepEqual(findAllAfter(paragraph, children[1]), res) | ||
assert.deepEqual(findAllAfter(paragraph, 1), res) | ||
assert.deepEqual(findAllAfter(paragraph, 7), []) | ||
assert.deepStrictEqual(findAllAfter(paragraph, children[1]), res) | ||
assert.deepStrictEqual(findAllAfter(paragraph, 1), res) | ||
assert.deepStrictEqual(findAllAfter(paragraph, 7), []) | ||
}, 'should return the following node when without `test`') | ||
t.doesNotThrow(function() { | ||
assert.deepEqual(findAllAfter(paragraph, 0, children[6]), [children[6]]) | ||
assert.deepEqual(findAllAfter(paragraph, children[0], children[1]), [ | ||
assert.deepStrictEqual(findAllAfter(paragraph, 0, children[6]), [ | ||
children[6] | ||
]) | ||
assert.deepStrictEqual(findAllAfter(paragraph, children[0], children[1]), [ | ||
children[1] | ||
]) | ||
assert.deepEqual(findAllAfter(paragraph, 0, children[1]), [children[1]]) | ||
assert.deepEqual(findAllAfter(paragraph, children[0], children[0]), []) | ||
assert.deepEqual(findAllAfter(paragraph, 0, children[0]), []) | ||
assert.deepEqual(findAllAfter(paragraph, 1, children[1]), []) | ||
assert.deepStrictEqual(findAllAfter(paragraph, 0, children[1]), [ | ||
children[1] | ||
]) | ||
assert.deepStrictEqual( | ||
findAllAfter(paragraph, children[0], children[0]), | ||
[] | ||
) | ||
assert.deepStrictEqual(findAllAfter(paragraph, 0, children[0]), []) | ||
assert.deepStrictEqual(findAllAfter(paragraph, 1, children[1]), []) | ||
}, 'should return `node` when given a `node` and existing') | ||
t.doesNotThrow(function() { | ||
assert.deepEqual(findAllAfter(paragraph, 0, 'strong'), [children[3]]) | ||
assert.deepEqual(findAllAfter(paragraph, 3, 'strong'), []) | ||
assert.deepEqual(findAllAfter(paragraph, children[0], 'strong'), [ | ||
assert.deepStrictEqual(findAllAfter(paragraph, 0, 'strong'), [children[3]]) | ||
assert.deepStrictEqual(findAllAfter(paragraph, 3, 'strong'), []) | ||
assert.deepStrictEqual(findAllAfter(paragraph, children[0], 'strong'), [ | ||
children[3] | ||
]) | ||
assert.deepEqual(findAllAfter(paragraph, children[3], 'strong'), []) | ||
assert.deepStrictEqual(findAllAfter(paragraph, children[3], 'strong'), []) | ||
}, 'should return a child when given a `type` and existing') | ||
@@ -99,6 +106,6 @@ | ||
assert.deepEqual(findAllAfter(paragraph, 0, test), res) | ||
assert.deepEqual(findAllAfter(paragraph, 6, test), []) | ||
assert.deepEqual(findAllAfter(paragraph, children[4], test), res) | ||
assert.deepEqual(findAllAfter(paragraph, children[6], test), []) | ||
assert.deepStrictEqual(findAllAfter(paragraph, 0, test), res) | ||
assert.deepStrictEqual(findAllAfter(paragraph, 6, test), []) | ||
assert.deepStrictEqual(findAllAfter(paragraph, children[4], test), res) | ||
assert.deepStrictEqual(findAllAfter(paragraph, children[6], test), []) | ||
@@ -105,0 +112,0 @@ function test(node, n) { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
12009
126
134
0