@webex/common 3.8.1 → 3.9.0-multi-llms.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/README.md +111 -18
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
# @webex/common
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
> Common functions for the Cisco Webex JS SDK.
|
|
6
|
-
|
|
7
|
-
- [Install](#install)
|
|
8
|
-
- [Usage](#usage)
|
|
9
|
-
- [Contribute](#contribute)
|
|
10
|
-
- [Maintainers](#maintainers)
|
|
11
|
-
- [License](#license)
|
|
3
|
+
Utility functions and helpers for the Cisco Webex JS SDK.
|
|
12
4
|
|
|
13
5
|
## Install
|
|
14
6
|
|
|
@@ -16,18 +8,119 @@
|
|
|
16
8
|
npm install --save @webex/common
|
|
17
9
|
```
|
|
18
10
|
|
|
11
|
+
## What it Does
|
|
12
|
+
|
|
13
|
+
This package provides essential utility functions used throughout the Webex SDK. While many exports are designed for internal SDK use, several utilities can be useful in general applications.
|
|
14
|
+
|
|
19
15
|
## Usage
|
|
20
16
|
|
|
21
|
-
|
|
17
|
+
### Capped Debounce
|
|
18
|
+
|
|
19
|
+
A debounce function that executes after a time delay OR after a maximum number of calls.
|
|
20
|
+
|
|
21
|
+
```js
|
|
22
|
+
import {cappedDebounce} from '@webex/common';
|
|
23
|
+
|
|
24
|
+
const debouncedFn = cappedDebounce(
|
|
25
|
+
() => console.log('Executed!'),
|
|
26
|
+
1000, // Wait 1 second
|
|
27
|
+
{
|
|
28
|
+
maxWait: 5000, // Execute after 5 seconds maximum
|
|
29
|
+
maxCalls: 10 // Execute after 10 calls maximum
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
// Will execute after 1 second of inactivity, 10 calls, or 5 seconds total
|
|
34
|
+
debouncedFn();
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Defer
|
|
38
|
+
|
|
39
|
+
Creates a deferred promise with exposed resolve/reject methods.
|
|
40
|
+
|
|
41
|
+
```js
|
|
42
|
+
import {Defer} from '@webex/common';
|
|
43
|
+
|
|
44
|
+
const deferred = new Defer();
|
|
45
|
+
|
|
46
|
+
// Resolve later
|
|
47
|
+
setTimeout(() => {
|
|
48
|
+
deferred.resolve('Success!');
|
|
49
|
+
}, 1000);
|
|
50
|
+
|
|
51
|
+
deferred.promise.then(result => {
|
|
52
|
+
console.log(result); // 'Success!'
|
|
53
|
+
});
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### One Flight
|
|
57
|
+
|
|
58
|
+
Decorator that ensures a method only runs one instance at a time, preventing duplicate calls.
|
|
59
|
+
|
|
60
|
+
```js
|
|
61
|
+
import {oneFlight} from '@webex/common';
|
|
62
|
+
|
|
63
|
+
class MyClass {
|
|
64
|
+
@oneFlight
|
|
65
|
+
async fetchData() {
|
|
66
|
+
// This will only run one instance at a time
|
|
67
|
+
// Subsequent calls while running will return the same promise
|
|
68
|
+
return await fetch('/api/data');
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Exception
|
|
74
|
+
|
|
75
|
+
Utility for creating custom error types.
|
|
76
|
+
|
|
77
|
+
```js
|
|
78
|
+
import {Exception} from '@webex/common';
|
|
79
|
+
|
|
80
|
+
const MyError = Exception.extend('MyError');
|
|
81
|
+
throw new MyError('Something went wrong');
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Tap
|
|
85
|
+
|
|
86
|
+
Utility for debugging promise chains without affecting the flow.
|
|
87
|
+
|
|
88
|
+
```js
|
|
89
|
+
import {tap} from '@webex/common';
|
|
90
|
+
|
|
91
|
+
fetch('/api/data')
|
|
92
|
+
.then(tap(response => console.log('Response received:', response)))
|
|
93
|
+
.then(response => response.json())
|
|
94
|
+
.then(tap(data => console.log('Data parsed:', data)));
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Deprecated
|
|
98
|
+
|
|
99
|
+
Decorator for marking methods as deprecated.
|
|
100
|
+
|
|
101
|
+
```js
|
|
102
|
+
import {deprecated} from '@webex/common';
|
|
103
|
+
|
|
104
|
+
class MyClass {
|
|
105
|
+
@deprecated('Use newMethod() instead')
|
|
106
|
+
oldMethod() {
|
|
107
|
+
// Will log deprecation warning when called
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Available Utilities
|
|
113
|
+
|
|
114
|
+
- **cappedDebounce** - Debounce with call count limit
|
|
115
|
+
- **defer** - Deferred promise creation
|
|
116
|
+
- **deprecated** - Deprecation warnings
|
|
117
|
+
- **exception** - Custom error types
|
|
118
|
+
- **oneFlight** - Prevent duplicate method calls
|
|
119
|
+
- **tap** - Debug promise chains
|
|
22
120
|
|
|
23
|
-
|
|
121
|
+
## SDK Integration
|
|
24
122
|
|
|
25
|
-
|
|
26
|
-
- [defer](./src/defer.js)
|
|
27
|
-
- [deprecated](./src/deprecated.js)
|
|
28
|
-
- [exception](./src/exception.js)
|
|
29
|
-
- [one-flight](./src/one-flight.js)
|
|
30
|
-
- [tap](./src/tap.js)
|
|
123
|
+
These utilities are primarily designed for use within the Webex SDK ecosystem but can be useful in any JavaScript application requiring these common patterns.
|
|
31
124
|
|
|
32
125
|
## Maintainers
|
|
33
126
|
|
|
@@ -39,4 +132,4 @@ Pull requests welcome. Please see [CONTRIBUTING.md](https://github.com/webex/web
|
|
|
39
132
|
|
|
40
133
|
## License
|
|
41
134
|
|
|
42
|
-
© 2016-
|
|
135
|
+
© 2016-2025 Cisco and/or its affiliates. All Rights Reserved.
|
package/package.json
CHANGED
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"@webex/eslint-config-legacy": "0.0.0",
|
|
30
30
|
"@webex/jest-config-legacy": "0.0.0",
|
|
31
31
|
"@webex/legacy-tools": "0.0.0",
|
|
32
|
-
"@webex/test-helper-chai": "3.
|
|
33
|
-
"@webex/test-helper-mocha": "3.
|
|
34
|
-
"@webex/test-helper-mock-webex": "3.
|
|
35
|
-
"@webex/test-helper-test-users": "3.
|
|
32
|
+
"@webex/test-helper-chai": "3.9.0-multi-llms.1",
|
|
33
|
+
"@webex/test-helper-mocha": "3.9.0-multi-llms.1",
|
|
34
|
+
"@webex/test-helper-mock-webex": "3.9.0-multi-llms.1",
|
|
35
|
+
"@webex/test-helper-test-users": "3.9.0-multi-llms.1",
|
|
36
36
|
"ampersand-state": "^5.0.3",
|
|
37
37
|
"eslint": "^8.24.0",
|
|
38
38
|
"prettier": "^2.7.1",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"test:style": "eslint ./src/**/*.*",
|
|
56
56
|
"test:unit": "webex-legacy-tools test --unit --runner jest"
|
|
57
57
|
},
|
|
58
|
-
"version": "3.
|
|
58
|
+
"version": "3.9.0-multi-llms.1"
|
|
59
59
|
}
|