@webex/common-evented 2.59.2 → 2.59.3-next.1

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/.eslintrc.js CHANGED
@@ -1,6 +1,6 @@
1
- const config = {
2
- root: true,
3
- extends: ['@webex/eslint-config-legacy'],
4
- };
5
-
6
- module.exports = config;
1
+ const config = {
2
+ root: true,
3
+ extends: ['@webex/eslint-config-legacy'],
4
+ };
5
+
6
+ module.exports = config;
package/README.md CHANGED
@@ -1,49 +1,49 @@
1
- # @webex/common-evented
2
-
3
- [![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
4
-
5
- > Class property decorator the adds change events to properties
6
-
7
- - [@webex/common-evented](#webexcommon-evented)
8
- - [Install](#install)
9
- - [Usage](#usage)
10
- - [Maintainers](#maintainers)
11
- - [Contribute](#contribute)
12
- - [License](#license)
13
-
14
- ## Install
15
-
16
- ```bash
17
- npm install --save @webex/common-evented
18
- ```
19
-
20
- ## Usage
21
-
22
- ```js
23
- const evented = require(`@webex/common-evented`);
24
- const Events = require(`ampersand-events`);
25
-
26
- class X extends Events {
27
- @evented
28
- prop = null;
29
- }
30
-
31
- const x = new X();
32
- x.on(`change:prop`, () => {
33
- console.log(x.prop);
34
- // => 6
35
- });
36
- x.prop = 6;
37
- ```
38
-
39
- ## Maintainers
40
-
41
- This package is maintained by [Cisco Webex for Developers](https://developer.webex.com/).
42
-
43
- ## Contribute
44
-
45
- Pull requests welcome. Please see [CONTRIBUTING.md](https://github.com/webex/webex-js-sdk/blob/master/CONTRIBUTING.md) for more details.
46
-
47
- ## License
48
-
49
- © 2016-2020 Cisco and/or its affiliates. All Rights Reserved.
1
+ # @webex/common-evented
2
+
3
+ [![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)
4
+
5
+ > Class property decorator the adds change events to properties
6
+
7
+ - [@webex/common-evented](#webexcommon-evented)
8
+ - [Install](#install)
9
+ - [Usage](#usage)
10
+ - [Maintainers](#maintainers)
11
+ - [Contribute](#contribute)
12
+ - [License](#license)
13
+
14
+ ## Install
15
+
16
+ ```bash
17
+ npm install --save @webex/common-evented
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ ```js
23
+ const evented = require(`@webex/common-evented`);
24
+ const Events = require(`ampersand-events`);
25
+
26
+ class X extends Events {
27
+ @evented
28
+ prop = null;
29
+ }
30
+
31
+ const x = new X();
32
+ x.on(`change:prop`, () => {
33
+ console.log(x.prop);
34
+ // => 6
35
+ });
36
+ x.prop = 6;
37
+ ```
38
+
39
+ ## Maintainers
40
+
41
+ This package is maintained by [Cisco Webex for Developers](https://developer.webex.com/).
42
+
43
+ ## Contribute
44
+
45
+ Pull requests welcome. Please see [CONTRIBUTING.md](https://github.com/webex/webex-js-sdk/blob/master/CONTRIBUTING.md) for more details.
46
+
47
+ ## License
48
+
49
+ © 2016-2020 Cisco and/or its affiliates. All Rights Reserved.
package/babel.config.js CHANGED
@@ -1,3 +1,3 @@
1
- const babelConfigLegacy = require('@webex/babel-config-legacy');
2
-
3
- module.exports = babelConfigLegacy;
1
+ const babelConfigLegacy = require('@webex/babel-config-legacy');
2
+
3
+ module.exports = babelConfigLegacy;
package/dist/index.js CHANGED
@@ -12,13 +12,13 @@ var _deleteProperty = _interopRequireDefault(require("@babel/runtime-corejs2/cor
12
12
  var _common = require("@webex/common");
13
13
  var data = new ((0, _common.make)(_weakMap.default, _map.default))();
14
14
 
15
- /**
16
- * Given a class property, this decorator changes it into a setter/getter pair;
17
- * the setter will trigger `change:${prop}` when invoked
18
- * @param {Object} target
19
- * @param {string} prop
20
- * @param {Object} descriptor
21
- * @returns {undefined}
15
+ /**
16
+ * Given a class property, this decorator changes it into a setter/getter pair;
17
+ * the setter will trigger `change:${prop}` when invoked
18
+ * @param {Object} target
19
+ * @param {string} prop
20
+ * @param {Object} descriptor
21
+ * @returns {undefined}
22
22
  */
23
23
  function evented(target, prop, descriptor) {
24
24
  var defaultValue = descriptor.initializer && descriptor.initializer();
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["_common","require","data","make","_weakMap","default","_map","evented","target","prop","descriptor","defaultValue","initializer","_deleteProperty","get","value","set","previous","trigger","concat"],"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,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAMC,IAAI,GAAG,KAAK,IAAAC,YAAI,EAAAC,QAAA,CAAAC,OAAA,EAAAC,IAAA,CAAAD,OAAA,CAAc,GAAG;;AAEvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASE,OAAOA,CAACC,MAAM,EAAEC,IAAI,EAAEC,UAAU,EAAE;EACxD,IAAMC,YAAY,GAAGD,UAAU,CAACE,WAAW,IAAIF,UAAU,CAACE,WAAW,EAAE;EAEvE,IAAAC,eAAA,CAAAR,OAAA,EAAuBK,UAAU,EAAE,OAAO,CAAC;EAC3C,IAAAG,eAAA,CAAAR,OAAA,EAAuBK,UAAU,EAAE,aAAa,CAAC;EACjD,IAAAG,eAAA,CAAAR,OAAA,EAAuBK,UAAU,EAAE,UAAU,CAAC;EAE9CA,UAAU,CAACI,GAAG,GAAG,SAASA,GAAGA,CAAA,EAAG;IAC9B,IAAMC,KAAK,GAAGb,IAAI,CAACY,GAAG,CAAC,IAAI,EAAEL,IAAI,CAAC;IAElC,IAAI,OAAOM,KAAK,KAAK,WAAW,EAAE;MAChC,OAAOA,KAAK;IACd;IAEA,OAAOJ,YAAY;EACrB,CAAC;EAEDD,UAAU,CAACM,GAAG,GAAG,SAASA,GAAGA,CAACD,KAAK,EAAE;IACnC,IAAME,QAAQ,GAAG,IAAI,CAACR,IAAI,CAAC;IAE3B,IAAIQ,QAAQ,KAAKF,KAAK,EAAE;MACtBb,IAAI,CAACc,GAAG,CAAC,IAAI,EAAEP,IAAI,EAAEM,KAAK,CAAC;MAC3B,IAAI,CAACG,OAAO,WAAAC,MAAA,CAAWV,IAAI,GAAIM,KAAK,EAAEE,QAAQ,CAAC;MAC/C,IAAI,CAACC,OAAO,CAAC,QAAQ,CAAC;IACxB;EACF,CAAC;AACH"}
1
+ {"version":3,"names":["_common","require","data","make","_weakMap","default","_map","evented","target","prop","descriptor","defaultValue","initializer","_deleteProperty","get","value","set","previous","trigger","concat"],"sources":["index.js"],"sourcesContent":["import {make} from '@webex/common';\r\n\r\nconst data = new (make(WeakMap, Map))();\r\n\r\n/**\r\n * Given a class property, this decorator changes it into a setter/getter pair;\r\n * the setter will trigger `change:${prop}` when invoked\r\n * @param {Object} target\r\n * @param {string} prop\r\n * @param {Object} descriptor\r\n * @returns {undefined}\r\n */\r\nexport default function evented(target, prop, descriptor) {\r\n const defaultValue = descriptor.initializer && descriptor.initializer();\r\n\r\n Reflect.deleteProperty(descriptor, 'value');\r\n Reflect.deleteProperty(descriptor, 'initializer');\r\n Reflect.deleteProperty(descriptor, 'writable');\r\n\r\n descriptor.get = function get() {\r\n const value = data.get(this, prop);\r\n\r\n if (typeof value !== 'undefined') {\r\n return value;\r\n }\r\n\r\n return defaultValue;\r\n };\r\n\r\n descriptor.set = function set(value) {\r\n const previous = this[prop];\r\n\r\n if (previous !== value) {\r\n data.set(this, prop, value);\r\n this.trigger(`change:${prop}`, value, previous);\r\n this.trigger('change');\r\n }\r\n };\r\n}\r\n"],"mappings":";;;;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAMC,IAAI,GAAG,KAAK,IAAAC,YAAI,EAAAC,QAAA,CAAAC,OAAA,EAAAC,IAAA,CAAAD,OAAA,CAAc,GAAG;;AAEvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASE,OAAOA,CAACC,MAAM,EAAEC,IAAI,EAAEC,UAAU,EAAE;EACxD,IAAMC,YAAY,GAAGD,UAAU,CAACE,WAAW,IAAIF,UAAU,CAACE,WAAW,EAAE;EAEvE,IAAAC,eAAA,CAAAR,OAAA,EAAuBK,UAAU,EAAE,OAAO,CAAC;EAC3C,IAAAG,eAAA,CAAAR,OAAA,EAAuBK,UAAU,EAAE,aAAa,CAAC;EACjD,IAAAG,eAAA,CAAAR,OAAA,EAAuBK,UAAU,EAAE,UAAU,CAAC;EAE9CA,UAAU,CAACI,GAAG,GAAG,SAASA,GAAGA,CAAA,EAAG;IAC9B,IAAMC,KAAK,GAAGb,IAAI,CAACY,GAAG,CAAC,IAAI,EAAEL,IAAI,CAAC;IAElC,IAAI,OAAOM,KAAK,KAAK,WAAW,EAAE;MAChC,OAAOA,KAAK;IACd;IAEA,OAAOJ,YAAY;EACrB,CAAC;EAEDD,UAAU,CAACM,GAAG,GAAG,SAASA,GAAGA,CAACD,KAAK,EAAE;IACnC,IAAME,QAAQ,GAAG,IAAI,CAACR,IAAI,CAAC;IAE3B,IAAIQ,QAAQ,KAAKF,KAAK,EAAE;MACtBb,IAAI,CAACc,GAAG,CAAC,IAAI,EAAEP,IAAI,EAAEM,KAAK,CAAC;MAC3B,IAAI,CAACG,OAAO,WAAAC,MAAA,CAAWV,IAAI,GAAIM,KAAK,EAAEE,QAAQ,CAAC;MAC/C,IAAI,CAACC,OAAO,CAAC,QAAQ,CAAC;IACxB;EACF,CAAC;AACH"}
package/jest.config.js CHANGED
@@ -1,3 +1,3 @@
1
- const config = require('@webex/jest-config-legacy');
2
-
3
- module.exports = config;
1
+ const config = require('@webex/jest-config-legacy');
2
+
3
+ module.exports = config;
package/package.json CHANGED
@@ -1,6 +1,5 @@
1
1
  {
2
2
  "name": "@webex/common-evented",
3
- "version": "2.59.2",
4
3
  "description": "Class property decorator the adds change events to properties",
5
4
  "license": "MIT",
6
5
  "main": "dist/index.js",
@@ -20,18 +19,18 @@
20
19
  ]
21
20
  },
22
21
  "dependencies": {
23
- "@webex/common": "2.59.2"
22
+ "@webex/common": "^2.59.3-next.1"
24
23
  },
25
24
  "devDependencies": {
26
25
  "@babel/core": "^7.17.10",
27
- "@webex/babel-config-legacy": "2.59.2",
28
- "@webex/eslint-config-legacy": "2.59.2",
29
- "@webex/jest-config-legacy": "2.59.2",
30
- "@webex/legacy-tools": "2.59.2",
31
- "@webex/test-helper-chai": "2.59.2",
32
- "@webex/test-helper-mocha": "2.59.2",
33
- "@webex/test-helper-mock-webex": "2.59.2",
34
- "@webex/test-helper-test-users": "2.59.2",
26
+ "@webex/babel-config-legacy": "^0.0.0",
27
+ "@webex/eslint-config-legacy": "^0.0.0",
28
+ "@webex/jest-config-legacy": "^0.0.0",
29
+ "@webex/legacy-tools": "^0.0.0",
30
+ "@webex/test-helper-chai": "^2.59.3-next.1",
31
+ "@webex/test-helper-mocha": "^2.59.3-next.1",
32
+ "@webex/test-helper-mock-webex": "^2.59.3-next.1",
33
+ "@webex/test-helper-test-users": "^2.59.3-next.1",
35
34
  "ampersand-events": "^2.0.2",
36
35
  "eslint": "^8.24.0",
37
36
  "prettier": "^2.7.1",
@@ -40,10 +39,12 @@
40
39
  "scripts": {
41
40
  "build": "yarn build:src",
42
41
  "build:src": "webex-legacy-tools build -dest \"./dist\" -src \"./src\" -js -ts -maps",
42
+ "deploy:npm": "yarn npm publish",
43
43
  "test": "yarn test:style && yarn test:unit && yarn test:integration && yarn test:browser",
44
44
  "test:browser": "webex-legacy-tools test --integration --unit --runner karma",
45
45
  "test:integration": "webex-legacy-tools test --integration --runner mocha",
46
46
  "test:style": "eslint ./src/**/*.*",
47
47
  "test:unit": "webex-legacy-tools test --unit --runner jest"
48
- }
49
- }
48
+ },
49
+ "version": "2.59.3-next.1"
50
+ }
package/process CHANGED
@@ -1 +1 @@
1
- module.exports = {browser: true};
1
+ module.exports = {browser: true};
package/src/index.js CHANGED
@@ -1,39 +1,39 @@
1
- import {make} from '@webex/common';
2
-
3
- const data = new (make(WeakMap, Map))();
4
-
5
- /**
6
- * Given a class property, this decorator changes it into a setter/getter pair;
7
- * the setter will trigger `change:${prop}` when invoked
8
- * @param {Object} target
9
- * @param {string} prop
10
- * @param {Object} descriptor
11
- * @returns {undefined}
12
- */
13
- export default function evented(target, prop, descriptor) {
14
- const defaultValue = descriptor.initializer && descriptor.initializer();
15
-
16
- Reflect.deleteProperty(descriptor, 'value');
17
- Reflect.deleteProperty(descriptor, 'initializer');
18
- Reflect.deleteProperty(descriptor, 'writable');
19
-
20
- descriptor.get = function get() {
21
- const value = data.get(this, prop);
22
-
23
- if (typeof value !== 'undefined') {
24
- return value;
25
- }
26
-
27
- return defaultValue;
28
- };
29
-
30
- descriptor.set = function set(value) {
31
- const previous = this[prop];
32
-
33
- if (previous !== value) {
34
- data.set(this, prop, value);
35
- this.trigger(`change:${prop}`, value, previous);
36
- this.trigger('change');
37
- }
38
- };
39
- }
1
+ import {make} from '@webex/common';
2
+
3
+ const data = new (make(WeakMap, Map))();
4
+
5
+ /**
6
+ * Given a class property, this decorator changes it into a setter/getter pair;
7
+ * the setter will trigger `change:${prop}` when invoked
8
+ * @param {Object} target
9
+ * @param {string} prop
10
+ * @param {Object} descriptor
11
+ * @returns {undefined}
12
+ */
13
+ export default function evented(target, prop, descriptor) {
14
+ const defaultValue = descriptor.initializer && descriptor.initializer();
15
+
16
+ Reflect.deleteProperty(descriptor, 'value');
17
+ Reflect.deleteProperty(descriptor, 'initializer');
18
+ Reflect.deleteProperty(descriptor, 'writable');
19
+
20
+ descriptor.get = function get() {
21
+ const value = data.get(this, prop);
22
+
23
+ if (typeof value !== 'undefined') {
24
+ return value;
25
+ }
26
+
27
+ return defaultValue;
28
+ };
29
+
30
+ descriptor.set = function set(value) {
31
+ const previous = this[prop];
32
+
33
+ if (previous !== value) {
34
+ data.set(this, prop, value);
35
+ this.trigger(`change:${prop}`, value, previous);
36
+ this.trigger('change');
37
+ }
38
+ };
39
+ }
@@ -1,47 +1,47 @@
1
- /*!
2
- * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
3
- */
4
-
5
- import evented from '@webex/common-evented';
6
- import Events from 'ampersand-events';
7
- import {assert} from '@webex/test-helper-chai';
8
- import sinon from 'sinon';
9
-
10
- describe('common-evented', () => {
11
- describe('@evented()', () => {
12
- class EventedClass {
13
- @evented
14
- prop = null;
15
- }
16
-
17
- Object.assign(EventedClass.prototype, Events);
18
-
19
- it('fires a specific change event', () => {
20
- const ec = new EventedClass();
21
- const spy = sinon.spy();
22
-
23
- ec.on('change:prop', spy);
24
- ec.prop = 1;
25
- assert.calledOnce(spy);
26
- });
27
-
28
- it('fires a generic change evnet', () => {
29
- const ec = new EventedClass();
30
- const spy = sinon.spy();
31
-
32
- ec.on('change', spy);
33
- ec.prop = 1;
34
- assert.calledOnce(spy);
35
- });
36
-
37
- it('fires the all event', () => {
38
- const ec = new EventedClass();
39
- const spy = sinon.spy();
40
-
41
- ec.on('all', spy);
42
- ec.prop = 1;
43
- // Once for `change:prop`, once for `change`
44
- assert.calledTwice(spy);
45
- });
46
- });
47
- });
1
+ /*!
2
+ * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
3
+ */
4
+
5
+ import evented from '@webex/common-evented';
6
+ import Events from 'ampersand-events';
7
+ import {assert} from '@webex/test-helper-chai';
8
+ import sinon from 'sinon';
9
+
10
+ describe('common-evented', () => {
11
+ describe('@evented()', () => {
12
+ class EventedClass {
13
+ @evented
14
+ prop = null;
15
+ }
16
+
17
+ Object.assign(EventedClass.prototype, Events);
18
+
19
+ it('fires a specific change event', () => {
20
+ const ec = new EventedClass();
21
+ const spy = sinon.spy();
22
+
23
+ ec.on('change:prop', spy);
24
+ ec.prop = 1;
25
+ assert.calledOnce(spy);
26
+ });
27
+
28
+ it('fires a generic change evnet', () => {
29
+ const ec = new EventedClass();
30
+ const spy = sinon.spy();
31
+
32
+ ec.on('change', spy);
33
+ ec.prop = 1;
34
+ assert.calledOnce(spy);
35
+ });
36
+
37
+ it('fires the all event', () => {
38
+ const ec = new EventedClass();
39
+ const spy = sinon.spy();
40
+
41
+ ec.on('all', spy);
42
+ ec.prop = 1;
43
+ // Once for `change:prop`, once for `change`
44
+ assert.calledTwice(spy);
45
+ });
46
+ });
47
+ });