.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / unist-util-find-all-after / index.js
1 'use strict'
2
3 var convert = require('unist-util-is/convert')
4
5 module.exports = findAllAfter
6
7 function findAllAfter(parent, index, test) {
8   var is = convert(test)
9   var results = []
10   var children
11   var child
12   var length
13
14   if (!parent || !parent.type || !parent.children) {
15     throw new Error('Expected parent node')
16   }
17
18   children = parent.children
19   length = children.length
20
21   if (index && index.type) {
22     index = children.indexOf(index)
23   }
24
25   if (isNaN(index) || index < 0 || index === Infinity) {
26     throw new Error('Expected positive finite index or child node')
27   }
28
29   while (++index < length) {
30     child = children[index]
31
32     if (is(child, index, parent)) {
33       results.push(child)
34     }
35   }
36
37   return results
38 }