@webex/common 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.
Files changed (80) hide show
  1. package/.eslintrc.js +6 -6
  2. package/README.md +42 -42
  3. package/babel.config.js +3 -3
  4. package/dist/base64.js +22 -22
  5. package/dist/base64.js.map +1 -1
  6. package/dist/browser-detection.js.map +1 -1
  7. package/dist/capped-debounce.js +12 -12
  8. package/dist/capped-debounce.js.map +1 -1
  9. package/dist/check-required.js +8 -8
  10. package/dist/check-required.js.map +1 -1
  11. package/dist/constants.js.map +1 -1
  12. package/dist/defer.js +13 -13
  13. package/dist/defer.js.map +1 -1
  14. package/dist/deprecated.js +5 -5
  15. package/dist/deprecated.js.map +1 -1
  16. package/dist/event-envelope.js +11 -11
  17. package/dist/event-envelope.js.map +1 -1
  18. package/dist/events.js +15 -15
  19. package/dist/events.js.map +1 -1
  20. package/dist/exception.js +13 -13
  21. package/dist/exception.js.map +1 -1
  22. package/dist/in-browser/browser.js +2 -2
  23. package/dist/in-browser/browser.js.map +1 -1
  24. package/dist/in-browser/index.js.map +1 -1
  25. package/dist/in-browser/node.js +2 -2
  26. package/dist/in-browser/node.js.map +1 -1
  27. package/dist/index.js.map +1 -1
  28. package/dist/isBuffer.js +6 -6
  29. package/dist/isBuffer.js.map +1 -1
  30. package/dist/make-state-datatype.js +14 -14
  31. package/dist/make-state-datatype.js.map +1 -1
  32. package/dist/one-flight.js +13 -13
  33. package/dist/one-flight.js.map +1 -1
  34. package/dist/patterns.js +30 -30
  35. package/dist/patterns.js.map +1 -1
  36. package/dist/resolve-with.js +19 -19
  37. package/dist/resolve-with.js.map +1 -1
  38. package/dist/retry.js +17 -17
  39. package/dist/retry.js.map +1 -1
  40. package/dist/tap.js +14 -14
  41. package/dist/tap.js.map +1 -1
  42. package/dist/template-container.js +51 -51
  43. package/dist/template-container.js.map +1 -1
  44. package/dist/uuid-utils.js +76 -76
  45. package/dist/uuid-utils.js.map +1 -1
  46. package/dist/while-in-flight.js +5 -5
  47. package/dist/while-in-flight.js.map +1 -1
  48. package/jest.config.js +3 -3
  49. package/package.json +12 -11
  50. package/process +1 -1
  51. package/src/base64.js +67 -67
  52. package/src/browser-detection.js +37 -37
  53. package/src/capped-debounce.js +65 -65
  54. package/src/check-required.js +18 -18
  55. package/src/constants.js +79 -79
  56. package/src/defer.js +24 -24
  57. package/src/deprecated.js +19 -19
  58. package/src/event-envelope.js +54 -54
  59. package/src/events.js +55 -55
  60. package/src/exception.js +45 -45
  61. package/src/in-browser/browser.js +5 -5
  62. package/src/in-browser/index.js +11 -11
  63. package/src/in-browser/node.js +5 -5
  64. package/src/index.js +44 -44
  65. package/src/isBuffer.js +12 -12
  66. package/src/make-state-datatype.js +91 -91
  67. package/src/one-flight.js +89 -89
  68. package/src/patterns.js +51 -51
  69. package/src/resolve-with.js +27 -27
  70. package/src/retry.js +124 -124
  71. package/src/tap.js +25 -25
  72. package/src/template-container.js +222 -222
  73. package/src/uuid-utils.js +189 -189
  74. package/src/while-in-flight.js +38 -38
  75. package/test/unit/spec/capped-debounce.js +103 -103
  76. package/test/unit/spec/common.js +42 -42
  77. package/test/unit/spec/exception.js +102 -102
  78. package/test/unit/spec/one-flight.js +211 -211
  79. package/test/unit/spec/template-container.js +81 -81
  80. package/test/unit/spec/while-in-flight.js +70 -70
@@ -1,42 +1,42 @@
1
- /*!
2
- * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
3
- */
4
-
5
- import {assert} from '@webex/test-helper-chai';
6
- import {base64, retry} from '@webex/common';
7
- import {Buffer} from 'safe-buffer';
8
-
9
- // This file doesn't prove anything, but greatly simplifies tooling. Generally
10
- // speaking, items in common are proven by their usage through the rest of
11
- // @webex.
12
-
13
- describe('common', () => {
14
- describe('base64', () => {
15
- it('is defined', () => {
16
- assert.isDefined(base64);
17
- });
18
-
19
- it('base64-encodes a string', () => {
20
- assert.equal(base64.toBase64Url('abc'), 'YWJj');
21
- });
22
-
23
- it('base64-encodes a buffer', () => {
24
- const buffer = Buffer.from('abc');
25
-
26
- assert.equal(base64.toBase64Url(buffer), 'YWJj');
27
- });
28
-
29
- it('base64-decodes a string', () => {
30
- const result = base64.fromBase64url('YWJj');
31
-
32
- assert.typeOf(result, 'string', 'decoded result must be type of string');
33
- assert.equal(result, 'abc');
34
- });
35
- });
36
-
37
- describe('retry', () => {
38
- it('is defined', () => {
39
- assert.isDefined(retry);
40
- });
41
- });
42
- });
1
+ /*!
2
+ * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
3
+ */
4
+
5
+ import {assert} from '@webex/test-helper-chai';
6
+ import {base64, retry} from '@webex/common';
7
+ import {Buffer} from 'safe-buffer';
8
+
9
+ // This file doesn't prove anything, but greatly simplifies tooling. Generally
10
+ // speaking, items in common are proven by their usage through the rest of
11
+ // @webex.
12
+
13
+ describe('common', () => {
14
+ describe('base64', () => {
15
+ it('is defined', () => {
16
+ assert.isDefined(base64);
17
+ });
18
+
19
+ it('base64-encodes a string', () => {
20
+ assert.equal(base64.toBase64Url('abc'), 'YWJj');
21
+ });
22
+
23
+ it('base64-encodes a buffer', () => {
24
+ const buffer = Buffer.from('abc');
25
+
26
+ assert.equal(base64.toBase64Url(buffer), 'YWJj');
27
+ });
28
+
29
+ it('base64-decodes a string', () => {
30
+ const result = base64.fromBase64url('YWJj');
31
+
32
+ assert.typeOf(result, 'string', 'decoded result must be type of string');
33
+ assert.equal(result, 'abc');
34
+ });
35
+ });
36
+
37
+ describe('retry', () => {
38
+ it('is defined', () => {
39
+ assert.isDefined(retry);
40
+ });
41
+ });
42
+ });
@@ -1,102 +1,102 @@
1
- /*!
2
- * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
3
- */
4
-
5
- import bowser from 'bowser';
6
- import {Exception} from '@webex/common';
7
- import {assert} from '@webex/test-helper-chai';
8
-
9
- describe('common', () => {
10
- describe('Exception', () => {
11
- describe('.parse()', () => {
12
- it('enables derived classes to override the default message', () => {
13
- class NoParserException extends Exception {
14
- static defaultMessage = 'no parser';
15
- }
16
-
17
- class DerivedNoParserException extends NoParserException {}
18
-
19
- class StaticBadParserException extends DerivedNoParserException {
20
- static parse() {
21
- return 'not really parsed';
22
- }
23
- }
24
-
25
- class NonStaticBadParserException extends StaticBadParserException {
26
- static parse() {
27
- return 'not really parsed, but like, totally not static';
28
- }
29
- }
30
-
31
- let e = new NoParserException();
32
-
33
- assert.match(e.message, /no parser/);
34
- assert.match(e.toString(), /no parser/);
35
-
36
- e = new DerivedNoParserException();
37
- assert.match(e.message, /no parser/);
38
- assert.match(e.toString(), /no parser/);
39
-
40
- e = new StaticBadParserException();
41
- assert.match(e.message, /not really parsed/);
42
- assert.match(e.toString(), /not really parsed/);
43
-
44
- e = new NonStaticBadParserException();
45
- assert.match(e.message, /not really parsed, but like, totally not static/);
46
- assert.match(e.toString(), /not really parsed, but like, totally not static/);
47
- });
48
- });
49
-
50
- describe('#defaultMessage', () => {
51
- it('gets used when no messsage is supplied', () => {
52
- let exception = new Exception();
53
-
54
- assert.match(exception.message, /An error occurred/);
55
- assert.match(exception.toString(), /An error occurred/);
56
-
57
- exception = new Exception(undefined);
58
- assert.match(exception.message, /An error occurred/);
59
- assert.match(exception.toString(), /An error occurred/);
60
-
61
- exception = new Exception(null);
62
- assert.match(exception.message, /An error occurred/);
63
- assert.match(exception.toString(), /An error occurred/);
64
-
65
- exception = new Exception('');
66
- assert.match(exception.message, /An error occurred/);
67
- assert.match(exception.toString(), /An error occurred/);
68
- });
69
-
70
- it('gets overridden by derived classes', () => {
71
- class MyException extends Exception {
72
- static defaultMessage = 'My exception occurred';
73
- }
74
- const exception = new MyException();
75
-
76
- assert.match(exception.message, /My exception occurred/);
77
- assert.match(exception.toString(), /My exception occurred/);
78
- });
79
-
80
- it('gets ignored when a string is supplied to the constructor', () => {
81
- const exception = new Exception('Something bad happened');
82
-
83
- assert.match(exception.message, /Something bad happened/);
84
- assert.match(exception.toString(), /Something bad happened/);
85
- });
86
- });
87
-
88
- // Skip in IE.
89
- (bowser.msie ? it.skip : it)('includes the exception class name when stringified', () => {
90
- class MyException extends Exception {
91
- static defaultMessage = 'My exception occurred';
92
- }
93
-
94
- let m = new MyException();
95
-
96
- assert.match(m.toString(), /MyException: My exception occurred/);
97
-
98
- m = new MyException('Your exception occurred');
99
- assert.match(m.toString(), /MyException: Your exception occurred/);
100
- });
101
- });
102
- });
1
+ /*!
2
+ * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
3
+ */
4
+
5
+ import bowser from 'bowser';
6
+ import {Exception} from '@webex/common';
7
+ import {assert} from '@webex/test-helper-chai';
8
+
9
+ describe('common', () => {
10
+ describe('Exception', () => {
11
+ describe('.parse()', () => {
12
+ it('enables derived classes to override the default message', () => {
13
+ class NoParserException extends Exception {
14
+ static defaultMessage = 'no parser';
15
+ }
16
+
17
+ class DerivedNoParserException extends NoParserException {}
18
+
19
+ class StaticBadParserException extends DerivedNoParserException {
20
+ static parse() {
21
+ return 'not really parsed';
22
+ }
23
+ }
24
+
25
+ class NonStaticBadParserException extends StaticBadParserException {
26
+ static parse() {
27
+ return 'not really parsed, but like, totally not static';
28
+ }
29
+ }
30
+
31
+ let e = new NoParserException();
32
+
33
+ assert.match(e.message, /no parser/);
34
+ assert.match(e.toString(), /no parser/);
35
+
36
+ e = new DerivedNoParserException();
37
+ assert.match(e.message, /no parser/);
38
+ assert.match(e.toString(), /no parser/);
39
+
40
+ e = new StaticBadParserException();
41
+ assert.match(e.message, /not really parsed/);
42
+ assert.match(e.toString(), /not really parsed/);
43
+
44
+ e = new NonStaticBadParserException();
45
+ assert.match(e.message, /not really parsed, but like, totally not static/);
46
+ assert.match(e.toString(), /not really parsed, but like, totally not static/);
47
+ });
48
+ });
49
+
50
+ describe('#defaultMessage', () => {
51
+ it('gets used when no messsage is supplied', () => {
52
+ let exception = new Exception();
53
+
54
+ assert.match(exception.message, /An error occurred/);
55
+ assert.match(exception.toString(), /An error occurred/);
56
+
57
+ exception = new Exception(undefined);
58
+ assert.match(exception.message, /An error occurred/);
59
+ assert.match(exception.toString(), /An error occurred/);
60
+
61
+ exception = new Exception(null);
62
+ assert.match(exception.message, /An error occurred/);
63
+ assert.match(exception.toString(), /An error occurred/);
64
+
65
+ exception = new Exception('');
66
+ assert.match(exception.message, /An error occurred/);
67
+ assert.match(exception.toString(), /An error occurred/);
68
+ });
69
+
70
+ it('gets overridden by derived classes', () => {
71
+ class MyException extends Exception {
72
+ static defaultMessage = 'My exception occurred';
73
+ }
74
+ const exception = new MyException();
75
+
76
+ assert.match(exception.message, /My exception occurred/);
77
+ assert.match(exception.toString(), /My exception occurred/);
78
+ });
79
+
80
+ it('gets ignored when a string is supplied to the constructor', () => {
81
+ const exception = new Exception('Something bad happened');
82
+
83
+ assert.match(exception.message, /Something bad happened/);
84
+ assert.match(exception.toString(), /Something bad happened/);
85
+ });
86
+ });
87
+
88
+ // Skip in IE.
89
+ (bowser.msie ? it.skip : it)('includes the exception class name when stringified', () => {
90
+ class MyException extends Exception {
91
+ static defaultMessage = 'My exception occurred';
92
+ }
93
+
94
+ let m = new MyException();
95
+
96
+ assert.match(m.toString(), /MyException: My exception occurred/);
97
+
98
+ m = new MyException('Your exception occurred');
99
+ assert.match(m.toString(), /MyException: Your exception occurred/);
100
+ });
101
+ });
102
+ });