diff options
author | Michaël Zasso <targos@protonmail.com> | 2017-12-22 16:53:42 +0100 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2018-01-11 09:48:05 +0100 |
commit | 3dc30632755713179f345f4af024bd904c6162d0 (patch) | |
tree | f28c4f6dd6dfc5992edf301449d1a371d229755b /tools/node_modules/eslint/node_modules/unist-util-is/readme.md | |
parent | a2c7085dd4a8e60d1a47572aca8bb6fcb7a32f88 (diff) | |
download | android-node-v8-3dc30632755713179f345f4af024bd904c6162d0.tar.gz android-node-v8-3dc30632755713179f345f4af024bd904c6162d0.tar.bz2 android-node-v8-3dc30632755713179f345f4af024bd904c6162d0.zip |
tools: move eslint from tools to tools/node_modules
This is required because we need to add the babel-eslint dependency
and it has to be able to resolve "eslint".
babel-eslint is required to support future ES features such as async
iterators and import.meta.
Refs: https://github.com/nodejs/node/pull/17755
PR-URL: https://github.com/nodejs/node/pull/17820
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Diffstat (limited to 'tools/node_modules/eslint/node_modules/unist-util-is/readme.md')
-rw-r--r-- | tools/node_modules/eslint/node_modules/unist-util-is/readme.md | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/tools/node_modules/eslint/node_modules/unist-util-is/readme.md b/tools/node_modules/eslint/node_modules/unist-util-is/readme.md new file mode 100644 index 0000000000..09bb5fc495 --- /dev/null +++ b/tools/node_modules/eslint/node_modules/unist-util-is/readme.md @@ -0,0 +1,120 @@ +# unist-util-is [![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov] + +[**Unist**][unist] utility to check if a node passes a test. + +## Installation + +[npm][]: + +```bash +npm install unist-util-is +``` + +## Usage + +```js +var is = require('unist-util-is'); + +var node = {type: 'strong'}; +var parent = {type: 'paragraph', children: [node]}; + +function test(node, n) { return n === 5 } + +is(); // false +is(null, {children: []}); // false +is(null, node); // true +is('strong', node); // true +is('emphasis', node); // false + +is(node, node) // true +is({type: 'paragraph'}, parent) // true +is({type: 'strong'}, parent) // false + +is(test, node); // false +is(test, node, 4, parent); // false +is(test, node, 5, parent); // true +``` + +## API + +### `is(test, node[, index, parent[, context]])` + +###### Parameters + +* `test` ([`Function`][test], `string`, `Object`, or `Array.<Test>`, optional) + — When not given, checks if `node` is a [`Node`][node]. + When `string`, works like passing `function (node) {return + node.type === test}`. + When `array`, checks any one of the subtests pass. + When `object`, checks that all keys in `test` are in `node`, + and that they have (strictly) equal values +* `node` ([`Node`][node]) — Node to check. `false` is returned +* `index` (`number`, optional) — Position of `node` in `parent` +* `parent` (`Node`, optional) — Parent of `node` +* `context` (`*`, optional) — Context object to invoke `test` with + +###### Returns + +`boolean` — Whether `test` passed _and_ `node` is a [`Node`][node] (object +with `type` set to non-empty `string`). + +#### `function test(node[, index, parent])` + +###### Parameters + +* `node` (`Node`) — Node to test +* `index` (`number?`) — Position of `node` in `parent` +* `parent` (`Node?`) — Parent of `node` + +###### Context + +`*` — The to `is` given `context`. + +###### Returns + +`boolean?` — Whether `node` matches. + +## Related + +* [`unist-util-find-after`](https://github.com/syntax-tree/unist-util-find-after) + — Find a node after another node +* [`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-find`](https://github.com/blahah/unist-util-find) + — Find nodes matching a predicate +* [`unist-util-filter`](https://github.com/eush77/unist-util-filter) + — Create a new tree with nodes that pass a check +* [`unist-util-remove`](https://github.com/eush77/unist-util-remove) + — Remove nodes from tree + +## License + +[MIT][license] © [Titus Wormer][author] + +<!-- Definitions --> + +[travis-badge]: https://img.shields.io/travis/syntax-tree/unist-util-is.svg + +[travis]: https://travis-ci.org/syntax-tree/unist-util-is + +[codecov-badge]: https://img.shields.io/codecov/c/github/syntax-tree/unist-util-is.svg + +[codecov]: https://codecov.io/github/syntax-tree/unist-util-is + +[npm]: https://docs.npmjs.com/cli/install + +[license]: LICENSE + +[author]: http://wooorm.com + +[unist]: https://github.com/syntax-tree/unist + +[node]: https://github.com/syntax-tree/unist#node + +[test]: #function-testnode-index-parent |