MCPcopy Index your code
hub / github.com/prettier/prettier / match

Method match

src/common/ast-path.js:203–232  ·  view source on GitHub ↗

* @param {...( * | ((node: any, name: string | null, number: number | null) => boolean) * | undefined * )} predicates

(...predicates)

Source from the content-addressed store, hash-verified

201 * )} predicates
202 */
203 match(...predicates) {
204 let stackPointer = this.stack.length - 1;
205
206 let name = null;
207 let node = this.stack[stackPointer--];
208
209 for (const predicate of predicates) {
210 /* c8 ignore next 3 */
211 if (node === undefined) {
212 return false;
213 }
214
215 // skip index/array
216 let number = null;
217 if (typeof name === "number") {
218 number = name;
219 name = this.stack[stackPointer--];
220 node = this.stack[stackPointer--];
221 }
222
223 if (predicate && !predicate(node, name, number)) {
224 return false;
225 }
226
227 name = this.stack[stackPointer--];
228 node = this.stack[stackPointer--];
229 }
230
231 return true;
232 }
233
234 /**
235 * Traverses the ancestors of the current node heading toward the tree root

Callers 15

getNodeCssStyleDisplayFunction · 0.45
parseVueVForDirectiveFunction · 0.45
formatRangeFunction · 0.45
getInterpreterFunction · 0.45
getIndentSizeFunction · 0.45
parseNestedCSSFunction · 0.45
getValueRootOffsetFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected