MCPcopy
hub / github.com/webpack/webpack / lazyObject

Function lazyObject

lib/ModuleFilenameHelpers.js:100–118  ·  view source on GitHub ↗
(obj)

Source from the content-addressed store, hash-verified

98 * @returns {Record<string, T>} the lazy access object
99 */
100const lazyObject = (obj) => {
101 const newObj = /** @type {Record<string, T>} */ ({});
102 for (const key of Object.keys(obj)) {
103 const fn = obj[key];
104 Object.defineProperty(newObj, key, {
105 get: () => fn(),
106 set: (v) => {
107 Object.defineProperty(newObj, key, {
108 value: v,
109 enumerable: true,
110 writable: true
111 });
112 },
113 enumerable: true,
114 configurable: true
115 });
116 }
117 return newObj;
118};
119
120const SQUARE_BRACKET_TAG_REGEXP = /\[\\*([\w-]+)\\*\]/g;
121/**

Callers 1

Calls 2

keysMethod · 0.65
fnFunction · 0.50

Tested by

no test coverage detected