@webex/common-evented 3.0.0-beta.2 → 3.0.0-beta.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -20,18 +20,17 @@ npm install --save @webex/common-evented
20
20
  ## Usage
21
21
 
22
22
  ```js
23
-
24
23
  const evented = require(`@webex/common-evented`);
25
24
  const Events = require(`ampersand-events`);
26
25
 
27
26
  class X extends Events {
28
27
  @evented
29
- prop = null
28
+ prop = null;
30
29
  }
31
30
 
32
31
  const x = new X();
33
32
  x.on(`change:prop`, () => {
34
- console.log(x.prop)
33
+ console.log(x.prop);
35
34
  // => 6
36
35
  });
37
36
  x.prop = 6;
package/dist/index.js CHANGED
@@ -1,24 +1,17 @@
1
1
  "use strict";
2
2
 
3
3
  var _Object$defineProperty = require("@babel/runtime-corejs2/core-js/object/define-property");
4
-
5
4
  var _interopRequireDefault = require("@babel/runtime-corejs2/helpers/interopRequireDefault");
6
-
7
5
  _Object$defineProperty(exports, "__esModule", {
8
6
  value: true
9
7
  });
10
-
11
8
  exports.default = evented;
12
-
13
9
  var _weakMap = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/weak-map"));
14
-
15
10
  var _map = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/map"));
16
-
17
11
  var _deleteProperty = _interopRequireDefault(require("@babel/runtime-corejs2/core-js/reflect/delete-property"));
18
-
19
12
  var _common = require("@webex/common");
20
-
21
13
  var data = new ((0, _common.make)(_weakMap.default, _map.default))();
14
+
22
15
  /**
23
16
  * Given a class property, this decorator changes it into a setter/getter pair;
24
17
  * the setter will trigger `change:${prop}` when invoked
@@ -27,26 +20,20 @@ var data = new ((0, _common.make)(_weakMap.default, _map.default))();
27
20
  * @param {Object} descriptor
28
21
  * @returns {undefined}
29
22
  */
30
-
31
23
  function evented(target, prop, descriptor) {
32
24
  var defaultValue = descriptor.initializer && descriptor.initializer();
33
25
  (0, _deleteProperty.default)(descriptor, 'value');
34
26
  (0, _deleteProperty.default)(descriptor, 'initializer');
35
27
  (0, _deleteProperty.default)(descriptor, 'writable');
36
-
37
28
  descriptor.get = function get() {
38
29
  var value = data.get(this, prop);
39
-
40
30
  if (typeof value !== 'undefined') {
41
31
  return value;
42
32
  }
43
-
44
33
  return defaultValue;
45
34
  };
46
-
47
35
  descriptor.set = function set(value) {
48
36
  var previous = this[prop];
49
-
50
37
  if (previous !== value) {
51
38
  data.set(this, prop, value);
52
39
  this.trigger("change:".concat(prop), value, previous);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["data","make","evented","target","prop","descriptor","defaultValue","initializer","get","value","set","previous","trigger"],"sources":["index.js"],"sourcesContent":["import {make} from '@webex/common';\n\nconst data = new (make(WeakMap, Map))();\n\n/**\n * Given a class property, this decorator changes it into a setter/getter pair;\n * the setter will trigger `change:${prop}` when invoked\n * @param {Object} target\n * @param {string} prop\n * @param {Object} descriptor\n * @returns {undefined}\n */\nexport default function evented(target, prop, descriptor) {\n const defaultValue = descriptor.initializer && descriptor.initializer();\n\n Reflect.deleteProperty(descriptor, 'value');\n Reflect.deleteProperty(descriptor, 'initializer');\n Reflect.deleteProperty(descriptor, 'writable');\n\n descriptor.get = function get() {\n const value = data.get(this, prop);\n\n if (typeof value !== 'undefined') {\n return value;\n }\n\n return defaultValue;\n };\n\n descriptor.set = function set(value) {\n const previous = this[prop];\n\n if (previous !== value) {\n data.set(this, prop, value);\n this.trigger(`change:${prop}`, value, previous);\n this.trigger('change');\n }\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;AAEA,IAAMA,IAAI,GAAG,KAAK,IAAAC,YAAA,iCAAL,GAAb;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACe,SAASC,OAAT,CAAiBC,MAAjB,EAAyBC,IAAzB,EAA+BC,UAA/B,EAA2C;EACxD,IAAMC,YAAY,GAAGD,UAAU,CAACE,WAAX,IAA0BF,UAAU,CAACE,WAAX,EAA/C;EAEA,6BAAuBF,UAAvB,EAAmC,OAAnC;EACA,6BAAuBA,UAAvB,EAAmC,aAAnC;EACA,6BAAuBA,UAAvB,EAAmC,UAAnC;;EAEAA,UAAU,CAACG,GAAX,GAAiB,SAASA,GAAT,GAAe;IAC9B,IAAMC,KAAK,GAAGT,IAAI,CAACQ,GAAL,CAAS,IAAT,EAAeJ,IAAf,CAAd;;IAEA,IAAI,OAAOK,KAAP,KAAiB,WAArB,EAAkC;MAChC,OAAOA,KAAP;IACD;;IAED,OAAOH,YAAP;EACD,CARD;;EAUAD,UAAU,CAACK,GAAX,GAAiB,SAASA,GAAT,CAAaD,KAAb,EAAoB;IACnC,IAAME,QAAQ,GAAG,KAAKP,IAAL,CAAjB;;IAEA,IAAIO,QAAQ,KAAKF,KAAjB,EAAwB;MACtBT,IAAI,CAACU,GAAL,CAAS,IAAT,EAAeN,IAAf,EAAqBK,KAArB;MACA,KAAKG,OAAL,kBAAuBR,IAAvB,GAA+BK,KAA/B,EAAsCE,QAAtC;MACA,KAAKC,OAAL,CAAa,QAAb;IACD;EACF,CARD;AASD"}
1
+ {"version":3,"names":["data","make","evented","target","prop","descriptor","defaultValue","initializer","get","value","set","previous","trigger"],"sources":["index.js"],"sourcesContent":["import {make} from '@webex/common';\n\nconst data = new (make(WeakMap, Map))();\n\n/**\n * Given a class property, this decorator changes it into a setter/getter pair;\n * the setter will trigger `change:${prop}` when invoked\n * @param {Object} target\n * @param {string} prop\n * @param {Object} descriptor\n * @returns {undefined}\n */\nexport default function evented(target, prop, descriptor) {\n const defaultValue = descriptor.initializer && descriptor.initializer();\n\n Reflect.deleteProperty(descriptor, 'value');\n Reflect.deleteProperty(descriptor, 'initializer');\n Reflect.deleteProperty(descriptor, 'writable');\n\n descriptor.get = function get() {\n const value = data.get(this, prop);\n\n if (typeof value !== 'undefined') {\n return value;\n }\n\n return defaultValue;\n };\n\n descriptor.set = function set(value) {\n const previous = this[prop];\n\n if (previous !== value) {\n data.set(this, prop, value);\n this.trigger(`change:${prop}`, value, previous);\n this.trigger('change');\n }\n };\n}\n"],"mappings":";;;;;;;;;;;AAAA;AAEA,IAAMA,IAAI,GAAG,KAAK,IAAAC,YAAI,iCAAc,GAAG;;AAEvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASC,OAAO,CAACC,MAAM,EAAEC,IAAI,EAAEC,UAAU,EAAE;EACxD,IAAMC,YAAY,GAAGD,UAAU,CAACE,WAAW,IAAIF,UAAU,CAACE,WAAW,EAAE;EAEvE,6BAAuBF,UAAU,EAAE,OAAO,CAAC;EAC3C,6BAAuBA,UAAU,EAAE,aAAa,CAAC;EACjD,6BAAuBA,UAAU,EAAE,UAAU,CAAC;EAE9CA,UAAU,CAACG,GAAG,GAAG,SAASA,GAAG,GAAG;IAC9B,IAAMC,KAAK,GAAGT,IAAI,CAACQ,GAAG,CAAC,IAAI,EAAEJ,IAAI,CAAC;IAElC,IAAI,OAAOK,KAAK,KAAK,WAAW,EAAE;MAChC,OAAOA,KAAK;IACd;IAEA,OAAOH,YAAY;EACrB,CAAC;EAEDD,UAAU,CAACK,GAAG,GAAG,SAASA,GAAG,CAACD,KAAK,EAAE;IACnC,IAAME,QAAQ,GAAG,IAAI,CAACP,IAAI,CAAC;IAE3B,IAAIO,QAAQ,KAAKF,KAAK,EAAE;MACtBT,IAAI,CAACU,GAAG,CAAC,IAAI,EAAEN,IAAI,EAAEK,KAAK,CAAC;MAC3B,IAAI,CAACG,OAAO,kBAAWR,IAAI,GAAIK,KAAK,EAAEE,QAAQ,CAAC;MAC/C,IAAI,CAACC,OAAO,CAAC,QAAQ,CAAC;IACxB;EACF,CAAC;AACH"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webex/common-evented",
3
- "version": "3.0.0-beta.2",
3
+ "version": "3.0.0-beta.20",
4
4
  "description": "Class property decorator the adds change events to properties",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -20,11 +20,11 @@
20
20
  ]
21
21
  },
22
22
  "dependencies": {
23
- "@webex/common": "3.0.0-beta.2"
23
+ "@webex/common": "3.0.0-beta.20"
24
24
  },
25
25
  "devDependencies": {
26
- "@webex/common-evented": "3.0.0-beta.2",
27
- "@webex/test-helper-chai": "3.0.0-beta.2",
26
+ "@webex/common-evented": "3.0.0-beta.20",
27
+ "@webex/test-helper-chai": "3.0.0-beta.20",
28
28
  "ampersand-events": "^2.0.2",
29
29
  "sinon": "^9.2.4"
30
30
  }
@@ -11,7 +11,7 @@ describe('common-evented', () => {
11
11
  describe('@evented()', () => {
12
12
  class EventedClass {
13
13
  @evented
14
- prop = null;
14
+ prop = null;
15
15
  }
16
16
 
17
17
  Object.assign(EventedClass.prototype, Events);