(target, property, receiver)
| 188 | // https://github.com/lorenwest/node-config/issues/514 |
| 189 | value = new Proxy(this.makeImmutable(value), { |
| 190 | get(target, property, receiver) { |
| 191 | // Bypass proxy receiver for properties directly on the target (e.g., RegExp.prototype.source) |
| 192 | // or properties that are not functions to prevent errors related to internal object methods. |
| 193 | if (Object.hasOwn(target, property) || (property in target && typeof target[property] !== 'function')) { |
| 194 | return Reflect.get(target, property); |
| 195 | } |
| 196 | |
| 197 | // Otherwise, use the proxy receiver to handle the property access |
| 198 | const ref = Reflect.get(target, property, receiver); |
| 199 | |
| 200 | // Binds the method's `this` context to the target object (e.g., Date.prototype.toISOString) |
| 201 | // to ensure it behaves correctly when called on the proxy. |
| 202 | if (typeof ref === 'function') { |
| 203 | return ref.bind(target); |
| 204 | } |
| 205 | return ref; |
| 206 | }, |
| 207 | set(target, name) { |
| 208 | const message = (Reflect.has(target, name) ? 'update' : 'add'); |
| 209 | // Notify the user. |
no outgoing calls
no test coverage detected