index.js 404 B

12345678910111213141516171819
  1. 'use strict';
  2. module.exports = (object, propertyName, fn) => {
  3. const define = value => Object.defineProperty(object, propertyName, {value, enumerable: true, writable: true});
  4. Object.defineProperty(object, propertyName, {
  5. configurable: true,
  6. enumerable: true,
  7. get() {
  8. const result = fn();
  9. define(result);
  10. return result;
  11. },
  12. set(value) {
  13. define(value);
  14. }
  15. });
  16. return object;
  17. };