diff options
Diffstat (limited to 'tools/node_modules/eslint/node_modules/unist-util-visit')
4 files changed, 312 insertions, 0 deletions
diff --git a/tools/node_modules/eslint/node_modules/unist-util-visit/LICENSE b/tools/node_modules/eslint/node_modules/unist-util-visit/LICENSE new file mode 100644 index 0000000000..32e7a3d93c --- /dev/null +++ b/tools/node_modules/eslint/node_modules/unist-util-visit/LICENSE @@ -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. diff --git a/tools/node_modules/eslint/node_modules/unist-util-visit/index.js b/tools/node_modules/eslint/node_modules/unist-util-visit/index.js new file mode 100644 index 0000000000..d51a97513b --- /dev/null +++ b/tools/node_modules/eslint/node_modules/unist-util-visit/index.js @@ -0,0 +1,55 @@ +'use strict'; + +/* Expose. */ +module.exports = visit; + +var is = require('unist-util-is'); + +/* Visit. */ +function visit(tree, test, visitor, reverse) { + if (typeof test === 'function' && typeof visitor !== 'function') { + reverse = visitor; + visitor = test; + test = null; + } + + one(tree); + + /* Visit a single node. */ + function one(node, index, parent) { + var result; + + index = index || (parent ? 0 : null); + + if (!test || node.type === test || is(test, node, index, parent || null)) { + result = visitor(node, index, parent || null); + } + + if (node.children && result !== false) { + return all(node.children, node); + } + + return result; + } + + /* Visit children in `parent`. */ + function all(children, parent) { + var step = reverse ? -1 : 1; + var max = children.length; + var min = -1; + var index = (reverse ? max : min) + step; + var child; + + while (index > min && index < max) { + child = children[index]; + + if (child && one(child, index, parent) === false) { + return false; + } + + index += step; + } + + return true; + } +} diff --git a/tools/node_modules/eslint/node_modules/unist-util-visit/package.json b/tools/node_modules/eslint/node_modules/unist-util-visit/package.json new file mode 100644 index 0000000000..f2964f8390 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/unist-util-visit/package.json @@ -0,0 +1,116 @@ +{ + "_from": "unist-util-visit@^1.1.0", + "_id": "unist-util-visit@1.2.0", + "_inBundle": false, + "_integrity": "sha512-lI+jyPlDztHZ2CJhUchcRMQ7MNc0yASgYFxwRTxs0EZ+9HbYFBLVGDJ2FchTBy+pra0O1LVEn0Wkgf19mDVDzw==", + "_location": "/unist-util-visit", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "unist-util-visit@^1.1.0", + "name": "unist-util-visit", + "escapedName": "unist-util-visit", + "rawSpec": "^1.1.0", + "saveSpec": null, + "fetchSpec": "^1.1.0" + }, + "_requiredBy": [ + "/unist-util-remove-position" + ], + "_resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-1.2.0.tgz", + "_shasum": "9dc78d1f95cd242e865f7f93f327d3296bb9a718", + "_spec": "unist-util-visit@^1.1.0", + "_where": "/Users/cjihrig/iojs/node/tools/eslint-tmp/node_modules/eslint/node_modules/unist-util-remove-position", + "author": { + "name": "Titus Wormer", + "email": "tituswormer@gmail.com", + "url": "http://wooorm.com" + }, + "bugs": { + "url": "https://github.com/syntax-tree/unist-util-visit/issues" + }, + "bundleDependencies": false, + "contributors": [ + { + "name": "Titus Wormer", + "email": "tituswormer@gmail.com", + "url": "http://wooorm.com" + }, + { + "name": "Eugene Sharygin", + "email": "eush77@gmail.com" + }, + { + "name": "Richard Gibson", + "email": "richard.gibson@gmail.com" + } + ], + "dependencies": { + "unist-util-is": "^2.1.1" + }, + "deprecated": false, + "description": "Recursively walk over unist nodes", + "devDependencies": { + "browserify": "^14.0.0", + "esmangle": "^1.0.0", + "nyc": "^11.0.0", + "remark": "^8.0.0", + "remark-cli": "^4.0.0", + "remark-preset-wooorm": "^3.0.0", + "tape": "^4.5.1", + "xo": "^0.18.2" + }, + "files": [ + "index.js" + ], + "homepage": "https://github.com/syntax-tree/unist-util-visit#readme", + "keywords": [ + "unist", + "remark", + "markdown", + "retext", + "natural", + "language", + "node", + "visit", + "walk", + "util", + "utility" + ], + "license": "MIT", + "name": "unist-util-visit", + "nyc": { + "check-coverage": true, + "lines": 100, + "functions": 100, + "branches": 100 + }, + "remarkConfig": { + "plugins": [ + "preset-wooorm" + ] + }, + "repository": { + "type": "git", + "url": "git+https://github.com/syntax-tree/unist-util-visit.git" + }, + "scripts": { + "build": "npm run build-md && npm run build-bundle && npm run build-mangle", + "build-bundle": "browserify index.js --no-builtins -s unistUtilVisit > unist-util-visit.js", + "build-mangle": "esmangle unist-util-visit.js > unist-util-visit.min.js", + "build-md": "remark . -qfo", + "lint": "xo", + "test": "npm run build && npm run lint && npm run test-coverage", + "test-api": "node test", + "test-coverage": "nyc --reporter lcov tape test.js" + }, + "version": "1.2.0", + "xo": { + "space": true, + "esnext": false, + "ignores": [ + "unist-util-visit.js" + ] + } +} diff --git a/tools/node_modules/eslint/node_modules/unist-util-visit/readme.md b/tools/node_modules/eslint/node_modules/unist-util-visit/readme.md new file mode 100644 index 0000000000..1d68eef6f8 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/unist-util-visit/readme.md @@ -0,0 +1,119 @@ +# unist-util-visit [![Build Status][build-badge]][build-page] [![Coverage Status][coverage-badge]][coverage-page] + +[Unist][] node visitor. Useful when working with [**remark**][remark], +[**retext**][retext], or [**rehype**][rehype]. + +## Installation + +[npm][]: + +```bash +npm install unist-util-visit +``` + +## Usage + +```javascript +var remark = require('remark'); +var visit = require('unist-util-visit'); + +var tree = remark.parse('Some _emphasis_, **importance**, and `code`.'); + +visit(tree, 'text', visitor); + +function visitor(node) { + console.log(node); +} +``` + +Yields: + +```js +{ type: 'text', value: 'Some ' } +{ type: 'text', value: 'emphasis' } +{ type: 'text', value: ', ' } +{ type: 'text', value: 'importance' } +{ type: 'text', value: ', and ' } +{ type: 'text', value: '.' } +``` + +## API + +### `visit(node[, test], visitor[, reverse])` + +Visit nodes. Optionally filtering nodes. Optionally in reverse. + +###### Parameters + +* `node` ([`Node`][node]) + — Node to search +* `test` ([`Test`][is], optional) + — Node type or other [`is`][is]-compatible test +* `visitor` ([Function][visitor]) + — Visitor invoked when a node is found +* `reverse` (`boolean`, default: `false`) + — When falsey, checking starts at the first child and continues + through to later children. When truthy, this is reversed. + This **does not** mean checking starts at the deepest node and + continues on to the highest node + +#### `stop? = visitor(node, index, parent)` + +Invoked when a node (matching `test`, if given) is found. + +###### Parameters + +* `node` (`Node`) — Found node +* `index` (`number?`) — Position of `node` in `parent` +* `parent` (`Node?`) — Parent of `node` + +###### Returns + +`boolean?` - When `false`, visiting is immediately stopped. + +## Related + +* [`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-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 + +## License + +[MIT][license] © [Titus Wormer][author] + +<!-- Definition --> + +[build-badge]: https://img.shields.io/travis/syntax-tree/unist-util-visit.svg + +[build-page]: https://travis-ci.org/syntax-tree/unist-util-visit + +[coverage-badge]: https://img.shields.io/codecov/c/github/syntax-tree/unist-util-visit.svg + +[coverage-page]: https://codecov.io/github/syntax-tree/unist-util-visit?branch=master + +[npm]: https://docs.npmjs.com/cli/install + +[license]: LICENSE + +[author]: http://wooorm.com + +[unist]: https://github.com/syntax-tree/unist + +[retext]: https://github.com/wooorm/retext + +[remark]: https://github.com/wooorm/remark + +[rehype]: https://github.com/wooorm/rehype + +[node]: https://github.com/syntax-tree/unist#node + +[is]: https://github.com/syntax-tree/unist-util-is#istest-node-index-parent-context + +[visitor]: #stop--visitornode-index-parent |