You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
404 B
19 lines
404 B
'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; |
|
};
|
|
|