MCPcopy
hub / github.com/prettier/prettier / each

Method each

src/common/ast-path.js:162–181  ·  view source on GitHub ↗
(callback, ...names)

Source from the content-addressed store, hash-verified

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

Callers 15

mapMethod · 0.95
printNodeFunction · 0.80
recurseFunction · 0.80
printTrailingCommentsFunction · 0.80
genericPrintFunction · 0.80
printSequenceFunction · 0.80
printSentenceFunction · 0.80
printChildrenFunction · 0.80
printStartingTagFunction · 0.80
iterateCallArgumentsPathFunction · 0.80
iterateClassMembersPathFunction · 0.80

Calls 2

atMethod · 0.80
callbackFunction · 0.50

Tested by

no test coverage detected