MCPcopy
hub / github.com/postcss/postcss / get

Method get

lib/container.js:90–125  ·  view source on GitHub ↗
(node, prop)

Source from the content-addressed store, hash-verified

88 getProxyProcessor() {
89 return {
90 get(node, prop) {
91 if (prop === 'proxyOf') {
92 return node
93 } else if (!node[prop]) {
94 return node[prop]
95 } else if (
96 prop === 'each' ||
97 (typeof prop === 'string' && prop.startsWith('walk'))
98 ) {
99 return (...args) => {
100 return node[prop](
101 ...args.map(i => {
102 if (typeof i === 'function') {
103 return (child, index) => i(child.toProxy(), index)
104 } else {
105 return i
106 }
107 })
108 )
109 }
110 } else if (prop === 'every' || prop === 'some') {
111 return cb => {
112 return node[prop]((child, ...other) =>
113 cb(child.toProxy(), ...other)
114 )
115 }
116 } else if (prop === 'root') {
117 return () => node.root().toProxy()
118 } else if (prop === 'nodes') {
119 return node.nodes.map(i => i.toProxy())
120 } else if (prop === 'first' || prop === 'last') {
121 return node[prop].toProxy()
122 } else {
123 return node[prop]
124 }
125 },
126
127 set(node, prop, value) {
128 if (node[prop] === value) return true

Callers

nothing calls this directly

Calls 3

toProxyMethod · 0.80
mapMethod · 0.45
rootMethod · 0.45

Tested by

no test coverage detected