This commit is contained in:
37
node_modules/unist-util-find-after/index.js
generated
vendored
Normal file
37
node_modules/unist-util-find-after/index.js
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
'use strict'
|
||||
|
||||
var convert = require('unist-util-is/convert')
|
||||
|
||||
module.exports = findAfter
|
||||
|
||||
function findAfter(parent, index, test) {
|
||||
var is = convert(test)
|
||||
var children
|
||||
var child
|
||||
var length
|
||||
|
||||
if (!parent || !parent.type || !parent.children) {
|
||||
throw new Error('Expected parent node')
|
||||
}
|
||||
|
||||
children = parent.children
|
||||
length = children.length
|
||||
|
||||
if (index && index.type) {
|
||||
index = children.indexOf(index)
|
||||
}
|
||||
|
||||
if (isNaN(index) || index < 0 || index === Infinity) {
|
||||
throw new Error('Expected positive finite index or child node')
|
||||
}
|
||||
|
||||
while (++index < length) {
|
||||
child = children[index]
|
||||
|
||||
if (is(child, index, parent)) {
|
||||
return child
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
22
node_modules/unist-util-find-after/license
generated
vendored
Normal file
22
node_modules/unist-util-find-after/license
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2015 Titus Wormer <tituswormer@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
77
node_modules/unist-util-find-after/package.json
generated
vendored
Normal file
77
node_modules/unist-util-find-after/package.json
generated
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
{
|
||||
"name": "unist-util-find-after",
|
||||
"version": "3.0.0",
|
||||
"description": "unist utility to find a node after another node",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"unist",
|
||||
"unist-util",
|
||||
"util",
|
||||
"utility",
|
||||
"node",
|
||||
"find",
|
||||
"after"
|
||||
],
|
||||
"repository": "syntax-tree/unist-util-find-after",
|
||||
"bugs": "https://github.com/syntax-tree/unist-util-find-after/issues",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/unified"
|
||||
},
|
||||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
|
||||
"contributors": [
|
||||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
|
||||
],
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"unist-util-is": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"browserify": "^16.0.0",
|
||||
"nyc": "^15.0.0",
|
||||
"prettier": "^1.0.0",
|
||||
"remark": "^11.0.0",
|
||||
"remark-cli": "^7.0.0",
|
||||
"remark-preset-wooorm": "^6.0.0",
|
||||
"tape": "^4.0.0",
|
||||
"tinyify": "^2.0.0",
|
||||
"xo": "^0.25.0"
|
||||
},
|
||||
"scripts": {
|
||||
"format": "remark . -qfo && prettier --write \"**/*.js\" && xo --fix",
|
||||
"build-bundle": "browserify . -s unistUtilFindAfter -o unist-util-find-after.js",
|
||||
"build-mangle": "browserify . -s unistUtilFindAfter -p tinyify -o unist-util-find-after.min.js",
|
||||
"build": "npm run build-bundle && npm run build-mangle",
|
||||
"test-api": "node test",
|
||||
"test-coverage": "nyc --reporter lcov tape test.js",
|
||||
"test": "npm run format && npm run build && npm run test-coverage"
|
||||
},
|
||||
"nyc": {
|
||||
"check-coverage": true,
|
||||
"lines": 100,
|
||||
"functions": 100,
|
||||
"branches": 100
|
||||
},
|
||||
"prettier": {
|
||||
"tabWidth": 2,
|
||||
"useTabs": false,
|
||||
"singleQuote": true,
|
||||
"bracketSpacing": false,
|
||||
"semi": false,
|
||||
"trailingComma": "none"
|
||||
},
|
||||
"xo": {
|
||||
"prettier": true,
|
||||
"esnext": false,
|
||||
"ignore": [
|
||||
"unist-util-find-after.js"
|
||||
]
|
||||
},
|
||||
"remarkConfig": {
|
||||
"plugins": [
|
||||
"preset-wooorm"
|
||||
]
|
||||
}
|
||||
}
|
||||
155
node_modules/unist-util-find-after/readme.md
generated
vendored
Normal file
155
node_modules/unist-util-find-after/readme.md
generated
vendored
Normal file
@@ -0,0 +1,155 @@
|
||||
# unist-util-find-after
|
||||
|
||||
[![Build][build-badge]][build]
|
||||
[![Coverage][coverage-badge]][coverage]
|
||||
[![Downloads][downloads-badge]][downloads]
|
||||
[![Size][size-badge]][size]
|
||||
[![Sponsors][sponsors-badge]][collective]
|
||||
[![Backers][backers-badge]][collective]
|
||||
[![Chat][chat-badge]][chat]
|
||||
|
||||
[**unist**][unist] utility to find a node after another node.
|
||||
|
||||
## Install
|
||||
|
||||
[npm][]:
|
||||
|
||||
```sh
|
||||
npm install unist-util-find-after
|
||||
```
|
||||
|
||||
## Use
|
||||
|
||||
```js
|
||||
var u = require('unist-builder')
|
||||
var findAfter = require('unist-util-find-after')
|
||||
|
||||
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(findAfter(tree, 1, 'node'))
|
||||
```
|
||||
|
||||
Yields:
|
||||
|
||||
```js
|
||||
{type: 'node', children: [{ type: 'leaf', value: 'leaf 5'}]}
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### `findAfter(parent, node|index[, test])`
|
||||
|
||||
Find the first [child][] after `index` (or `node`) in `parent`, that passes
|
||||
`test`.
|
||||
|
||||
###### Parameters
|
||||
|
||||
* `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]
|
||||
|
||||
###### Returns
|
||||
|
||||
[`Node?`][node] — [Child][] of `parent` passing `test`.
|
||||
|
||||
## Related
|
||||
|
||||
* [`unist-util-visit`](https://github.com/syntax-tree/unist-util-visit)
|
||||
— Recursively walk over nodes
|
||||
* [`unist-util-visit-parents`](https://github.com/syntax-tree/unist-util-visit-parents)
|
||||
— Like `visit`, but with a stack of parents
|
||||
* [`unist-util-filter`](https://github.com/eush77/unist-util-filter)
|
||||
— Create a new tree with all nodes that pass a test
|
||||
* [`unist-util-map`](https://github.com/syntax-tree/unist-util-map)
|
||||
— Create a new tree with all nodes mapped by a given function
|
||||
* [`unist-util-flatmap`](https://gitlab.com/staltz/unist-util-flatmap)
|
||||
— Create a new tree by mapping (to an array) with the provided function and
|
||||
then flattening
|
||||
* [`unist-util-find-before`](https://github.com/syntax-tree/unist-util-find-before)
|
||||
— Find a node before another node
|
||||
* [`unist-util-find-all-after`](https://github.com/syntax-tree/unist-util-find-all-after)
|
||||
— Find all nodes after another node
|
||||
* [`unist-util-find-all-before`](https://github.com/syntax-tree/unist-util-find-all-before)
|
||||
— Find all nodes before another node
|
||||
* [`unist-util-find-all-between`](https://github.com/mrzmmr/unist-util-find-all-between)
|
||||
— Find all nodes between two nodes
|
||||
* [`unist-util-remove`](https://github.com/eush77/unist-util-remove)
|
||||
— Remove nodes from a tree that pass a test
|
||||
* [`unist-util-select`](https://github.com/eush77/unist-util-select)
|
||||
— Select nodes with CSS-like selectors
|
||||
|
||||
## Contribute
|
||||
|
||||
See [`contributing.md` in `syntax-tree/.github`][contributing] for ways to get
|
||||
started.
|
||||
See [`support.md`][support] for ways to get help.
|
||||
|
||||
This project has a [Code of Conduct][coc].
|
||||
By interacting with this repository, organisation, or community you agree to
|
||||
abide by its terms.
|
||||
|
||||
## License
|
||||
|
||||
[MIT][license] © [Titus Wormer][author]
|
||||
|
||||
<!-- Definitions -->
|
||||
|
||||
[build-badge]: https://img.shields.io/travis/syntax-tree/unist-util-find-after.svg
|
||||
|
||||
[build]: https://travis-ci.org/syntax-tree/unist-util-find-after
|
||||
|
||||
[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/unist-util-find-after.svg
|
||||
|
||||
[coverage]: https://codecov.io/github/syntax-tree/unist-util-find-after
|
||||
|
||||
[downloads-badge]: https://img.shields.io/npm/dm/unist-util-find-after.svg
|
||||
|
||||
[downloads]: https://www.npmjs.com/package/unist-util-find-after
|
||||
|
||||
[size-badge]: https://img.shields.io/bundlephobia/minzip/unist-util-find-after.svg
|
||||
|
||||
[size]: https://bundlephobia.com/result?p=unist-util-find-after
|
||||
|
||||
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
|
||||
|
||||
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
|
||||
|
||||
[collective]: https://opencollective.com/unified
|
||||
|
||||
[chat-badge]: https://img.shields.io/badge/chat-spectrum-7b16ff.svg
|
||||
|
||||
[chat]: https://spectrum.chat/unified/syntax-tree
|
||||
|
||||
[npm]: https://docs.npmjs.com/cli/install
|
||||
|
||||
[license]: license
|
||||
|
||||
[author]: https://wooorm.com
|
||||
|
||||
[unist]: https://github.com/syntax-tree/unist
|
||||
|
||||
[node]: https://github.com/syntax-tree/unist#node
|
||||
|
||||
[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/.github/blob/master/contributing.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
|
||||
Reference in New Issue
Block a user