tg-bot-reminder/node_modules/define-lazy-prop/index.js
2023-08-13 16:48:04 +03:00

19 lines
429 B
JavaScript

export default function defineLazyProperty(object, propertyName, valueGetter) {
const define = value => Object.defineProperty(object, propertyName, {value, enumerable: true, writable: true});
Object.defineProperty(object, propertyName, {
configurable: true,
enumerable: true,
get() {
const result = valueGetter();
define(result);
return result;
},
set(value) {
define(value);
}
});
return object;
}