|
8 | 8 | [![Backers][backers-badge]][collective] |
9 | 9 | [![Chat][chat-badge]][chat] |
10 | 10 |
|
11 | | -[**Unist**][unist] utility to check if a node passes a test. |
| 11 | +[**unist**][unist] utility to check if a node passes a test. |
12 | 12 |
|
13 | | -## Installation |
| 13 | +## Install |
14 | 14 |
|
15 | 15 | [npm][]: |
16 | 16 |
|
17 | | -```bash |
| 17 | +```sh |
18 | 18 | npm install unist-util-is |
19 | 19 | ``` |
20 | 20 |
|
@@ -53,20 +53,19 @@ is(test, node, 5, parent) // => true |
53 | 53 |
|
54 | 54 | * `test` ([`Function`][test], `string`, `Object`, or `Array.<Test>`, optional) |
55 | 55 | — When not given, checks if `node` is a [`Node`][node]. |
56 | | - When `string`, works like passing `function (node) {return |
57 | | - node.type === test}`. |
58 | | - When `array`, checks any one of the subtests pass. |
| 56 | + When `string`, works like passing `node => node.type === test`. |
| 57 | + When `array`, checks if any one of the subtests pass. |
59 | 58 | When `object`, checks that all keys in `test` are in `node`, |
60 | | - and that they have (strictly) equal values |
| 59 | + and that they have strictly equal values |
61 | 60 | * `node` ([`Node`][node]) — Node to check. `false` is returned |
62 | | -* `index` (`number`, optional) — Position of `node` in `parent` |
63 | | -* `parent` (`Node`, optional) — Parent of `node` |
| 61 | +* `index` (`number`, optional) — [Index][] of `node` in `parent` |
| 62 | +* `parent` ([`Node`][node], optional) — [Parent][] of `node` |
64 | 63 | * `context` (`*`, optional) — Context object to invoke `test` with |
65 | 64 |
|
66 | 65 | ###### Returns |
67 | 66 |
|
68 | 67 | `boolean` — Whether `test` passed *and* `node` is a [`Node`][node] (object |
69 | | -with `type` set to non-empty `string`). |
| 68 | +with `type` set to a non-empty `string`). |
70 | 69 |
|
71 | 70 | #### `function test(node[, index, parent])` |
72 | 71 |
|
@@ -105,11 +104,13 @@ with `type` set to non-empty `string`). |
105 | 104 |
|
106 | 105 | ## Contribute |
107 | 106 |
|
108 | | -See [`contributing.md` in `syntax-tree/unist`][contributing] for ways to get |
| 107 | +See [`contributing.md` in `syntax-tree/.github`][contributing] for ways to get |
109 | 108 | started. |
| 109 | +See [`support.md`][support] for ways to get help. |
110 | 110 |
|
111 | | -This organisation has a [Code of Conduct][coc]. By interacting with this |
112 | | -repository, organisation, or community you agree to abide by its terms. |
| 111 | +This project has a [Code of Conduct][coc]. |
| 112 | +By interacting with this repository, organisation, or community you agree to |
| 113 | +abide by its terms. |
113 | 114 |
|
114 | 115 | ## License |
115 | 116 |
|
@@ -149,12 +150,18 @@ repository, organisation, or community you agree to abide by its terms. |
149 | 150 |
|
150 | 151 | [author]: https://wooorm.com |
151 | 152 |
|
| 153 | +[contributing]: https://github.com/syntax-tree/.github/blob/master/contributing.md |
| 154 | + |
| 155 | +[support]: https://github.com/syntax-tree/.github/blob/master/support.md |
| 156 | + |
| 157 | +[coc]: https://github.com/syntax-tree/.github/blob/master/code-of-conduct.md |
| 158 | + |
152 | 159 | [unist]: https://github.com/syntax-tree/unist |
153 | 160 |
|
154 | 161 | [node]: https://github.com/syntax-tree/unist#node |
155 | 162 |
|
156 | | -[test]: #function-testnode-index-parent |
| 163 | +[parent]: https://github.com/syntax-tree/unist#parent-1 |
157 | 164 |
|
158 | | -[contributing]: https://github.com/syntax-tree/unist/blob/master/contributing.md |
| 165 | +[index]: https://github.com/syntax-tree/unist#index |
159 | 166 |
|
160 | | -[coc]: https://github.com/syntax-tree/unist/blob/master/code-of-conduct.md |
| 167 | +[test]: #function-testnode-index-parent |
0 commit comments