MCPcopy
hub / github.com/prettier/prettier / map

Method map

src/language-html/parse/ast.js:55–79  ·  view source on GitHub ↗
(fn)

Source from the content-addressed store, hash-verified

53 }
54
55 map(fn) {
56 /** @type{any} */
57 let newNode;
58
59 for (const NODES_KEY in NODES_KEYS) {
60 const nodes = this[NODES_KEY];
61 if (nodes) {
62 const mappedNodes = mapNodesIfChanged(nodes, (node) => node.map(fn));
63 if (newNode !== nodes) {
64 newNode ??= new Node({ parent: this.parent });
65 newNode.setProperty(NODES_KEY, mappedNodes);
66 }
67 }
68 }
69
70 if (newNode) {
71 for (const key in this) {
72 if (!(key in NODES_KEYS)) {
73 newNode[key] = this[key];
74 }
75 }
76 }
77
78 return fn(newNode || this);
79 }
80
81 walk(fn) {
82 for (const NODES_KEY in NODES_KEYS) {

Callers 15

getCssStyleTagsFunction · 0.45
genericPrintFunction · 0.45
setPropertyMethod · 0.45
attrMapMethod · 0.45
mapNodesIfChangedFunction · 0.45
parseFunction · 0.45
attribute.jsFile · 0.45
printPermissionsPolicyFunction · 0.45
printSrcsetFunction · 0.45

Calls 3

mapNodesIfChangedFunction · 0.85
setPropertyMethod · 0.80
fnFunction · 0.50

Tested by

no test coverage detected