(callback, ...names)
| 160 | // callback will be called with a reference to this path object for each |
| 161 | // element of the array. |
| 162 | each(callback, ...names) { |
| 163 | const { stack } = this; |
| 164 | const { length } = stack; |
| 165 | let value = stack.at(-1); |
| 166 | |
| 167 | for (const name of names) { |
| 168 | value = value[name]; |
| 169 | stack.push(name, value); |
| 170 | } |
| 171 | |
| 172 | try { |
| 173 | for (let i = 0; i < value.length; ++i) { |
| 174 | stack.push(i, value[i]); |
| 175 | callback(this, i, value); |
| 176 | stack.length -= 2; |
| 177 | } |
| 178 | } finally { |
| 179 | stack.length = length; |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | // Similar to AstPath.prototype.each, except that the results of the |
| 184 | // callback function invocations are stored in an array and returned at |
no test coverage detected