Frontend/25_01_07/mai/node_modules/define-lazy-prop/index.js
szabomarton 7f4a15b9c3 asd
2025-01-28 11:38:27 +01:00

20 lines
404 B
JavaScript

'use strict';
module.exports = (object, propertyName, fn) => {
const define = value => Object.defineProperty(object, propertyName, {value, enumerable: true, writable: true});
Object.defineProperty(object, propertyName, {
configurable: true,
enumerable: true,
get() {
const result = fn();
define(result);
return result;
},
set(value) {
define(value);
}
});
return object;
};