source: trip-planner-front/node_modules/define-lazy-prop/index.js@ fa375fe

Last change on this file since fa375fe was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 404 bytes
RevLine 
[6a3a178]1'use strict';
2module.exports = (object, propertyName, fn) => {
3 const define = value => Object.defineProperty(object, propertyName, {value, enumerable: true, writable: true});
4
5 Object.defineProperty(object, propertyName, {
6 configurable: true,
7 enumerable: true,
8 get() {
9 const result = fn();
10 define(result);
11 return result;
12 },
13 set(value) {
14 define(value);
15 }
16 });
17
18 return object;
19};
Note: See TracBrowser for help on using the repository browser.