MCPcopy
hub / github.com/webpack/webpack / propertyAccess

Function propertyAccess

lib/util/property.js:82–101  ·  view source on GitHub ↗
(properties, start = 0)

Source from the content-addressed store, hash-verified

80 * @returns {string} chain of property accesses
81 */
82const propertyAccess = (properties, start = 0) => {
83 let str = "";
84 for (let i = start; i < properties.length; i++) {
85 const p = properties[i];
86 // Only first chars 0-9, "-", "N", "I" can begin a canonical numeric form
87 // (number, NaN, Infinity); skip the Number() round-trip otherwise.
88 const c = p.charCodeAt(0);
89 if (
90 ((c >= 48 && c <= 57) || c === 45 || c === 78 || c === 73) &&
91 `${Number(p)}` === p
92 ) {
93 str += `[${p}]`;
94 } else if (SAFE_IDENTIFIER.test(p) && !RESERVED_IDENTIFIER.has(p)) {
95 str += `.${p}`;
96 } else {
97 str += `[${JSON.stringify(p)}]`;
98 }
99 }
100 return str;
101};
102
103module.exports = {
104 RESERVED_IDENTIFIER,

Calls 2

testMethod · 0.45
hasMethod · 0.45

Tested by

no test coverage detected