@webex/common-timers 3.10.0 → 3.11.0
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/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -73,7 +73,7 @@ var Timer = exports.Timer = /*#__PURE__*/function () {
|
|
|
73
73
|
* Start timer
|
|
74
74
|
* @returns {void}
|
|
75
75
|
*/
|
|
76
|
-
(0, _createClass2.default)(Timer, [{
|
|
76
|
+
return (0, _createClass2.default)(Timer, [{
|
|
77
77
|
key: "start",
|
|
78
78
|
value: function start() {
|
|
79
79
|
if (this.state !== 'init') {
|
|
@@ -133,6 +133,5 @@ var Timer = exports.Timer = /*#__PURE__*/function () {
|
|
|
133
133
|
clearTimeout(this.currentTimer);
|
|
134
134
|
}
|
|
135
135
|
}]);
|
|
136
|
-
return Timer;
|
|
137
136
|
}();
|
|
138
137
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["safeSetTimeout","timer","setTimeout","apply","arguments","unref","safeSetInterval","interval","setInterval","Timer","exports","callback","timeout","_this","_classCallCheck2","default","_defineProperty2","state","_createClass2","key","value","start","Error","concat","startTimer","reset","clearTimer","cancel","currentTimer","clearTimeout"],"sources":["index.ts"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n/**\n * Wrapper around setTimout which (in node) unrefs the returned timer to avoid\n * wedging the process open unexpectedly.\n * @param {Mixed} args\n * @protected\n * @returns {NodeJS.Timeout|Number}\n */\nexport function safeSetTimeout(...args: Parameters<typeof setTimeout>): number | NodeJS.Timeout {\n const timer = setTimeout(...args);\n\n if (timer.unref) {\n timer.unref();\n }\n\n return timer;\n}\n\n/**\n * Wrapper around setInterval which (in node) unrefs the returned timer to avoid\n * wedging the process open unexpectedly.\n * @param {Mixed} args\n * @protected\n * @returns {NodeJS.Timeout|Number}\n */\nexport function safeSetInterval(...args: Parameters<typeof setInterval>): number | NodeJS.Timeout {\n const interval = setInterval(...args);\n\n if (interval.unref) {\n interval.unref();\n }\n\n return interval;\n}\n\n/**\n * Create a restartable timer\n */\nexport class Timer {\n private state: 'init' | 'running' | 'done';\n private readonly timeout: number;\n private readonly callback: () => void;\n private currentTimer: number | NodeJS.Timeout;\n\n /**\n * Construct timer\n * @param {Function} callback Function called when the timer expired\n * @param {number} timeout duration of the timeout in milliseconds\n */\n constructor(callback: () => void, timeout: number) {\n this.state = 'init';\n this.timeout = timeout;\n this.callback = () => {\n this.state = 'done';\n callback();\n };\n }\n\n /**\n * Start timer\n * @returns {void}\n */\n start() {\n if (this.state !== 'init') {\n throw new Error(`Can't start the timer when it's in ${this.state} state`);\n }\n\n this.startTimer();\n this.state = 'running';\n }\n\n /**\n * Clear the current timer and start a new one\n * @returns {void}\n */\n reset() {\n if (this.state !== 'running') {\n throw new Error(`Can't reset the timer when it's in ${this.state} state`);\n }\n this.clearTimer();\n this.startTimer();\n }\n\n /**\n * Clear the timer\n * @returns {void}\n */\n cancel() {\n if (this.state !== 'running') {\n throw new Error(`Can't cancel the timer when it's in ${this.state} state`);\n }\n this.clearTimer();\n this.state = 'done';\n }\n\n /**\n * Create the actual timer\n * @private\n * @returns {undefined}\n */\n private startTimer() {\n this.currentTimer = safeSetTimeout(this.callback, this.timeout);\n }\n\n /**\n * Clear the actual timer\n * @private\n * @returns {undefined}\n */\n private clearTimer() {\n clearTimeout(this.currentTimer);\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAAA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,cAAcA,CAAA,EAAkE;EAC9F,IAAMC,KAAK,GAAGC,UAAU,CAAAC,KAAA,SAAAC,SAAQ,CAAC;EAEjC,IAAIH,KAAK,CAACI,KAAK,EAAE;IACfJ,KAAK,CAACI,KAAK,CAAC,CAAC;EACf;EAEA,OAAOJ,KAAK;AACd;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASK,eAAeA,CAAA,EAAmE;EAChG,IAAMC,QAAQ,GAAGC,WAAW,CAAAL,KAAA,SAAAC,SAAQ,CAAC;EAErC,IAAIG,QAAQ,CAACF,KAAK,EAAE;IAClBE,QAAQ,CAACF,KAAK,CAAC,CAAC;EAClB;EAEA,OAAOE,QAAQ;AACjB;;AAEA;AACA;AACA;AAFA,IAGaE,KAAK,GAAAC,OAAA,CAAAD,KAAA;EAMhB;AACF;AACA;AACA;AACA;EACE,SAAAA,MAAYE,QAAoB,EAAEC,OAAe,EAAE;IAAA,IAAAC,KAAA;IAAA,IAAAC,gBAAA,CAAAC,OAAA,QAAAN,KAAA;IAAA,IAAAO,gBAAA,CAAAD,OAAA;IAAA,IAAAC,gBAAA,CAAAD,OAAA;IAAA,IAAAC,gBAAA,CAAAD,OAAA;IAAA,IAAAC,gBAAA,CAAAD,OAAA;IACjD,IAAI,CAACE,KAAK,GAAG,MAAM;IACnB,IAAI,CAACL,OAAO,GAAGA,OAAO;IACtB,IAAI,CAACD,QAAQ,GAAG,YAAM;MACpBE,KAAI,CAACI,KAAK,GAAG,MAAM;MACnBN,QAAQ,CAAC,CAAC;IACZ,CAAC;EACH;;EAEA;AACF;AACA;AACA;EAHE,
|
|
1
|
+
{"version":3,"names":["safeSetTimeout","timer","setTimeout","apply","arguments","unref","safeSetInterval","interval","setInterval","Timer","exports","callback","timeout","_this","_classCallCheck2","default","_defineProperty2","state","_createClass2","key","value","start","Error","concat","startTimer","reset","clearTimer","cancel","currentTimer","clearTimeout"],"sources":["index.ts"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\n/**\n * Wrapper around setTimout which (in node) unrefs the returned timer to avoid\n * wedging the process open unexpectedly.\n * @param {Mixed} args\n * @protected\n * @returns {NodeJS.Timeout|Number}\n */\nexport function safeSetTimeout(...args: Parameters<typeof setTimeout>): number | NodeJS.Timeout {\n const timer = setTimeout(...args);\n\n if (timer.unref) {\n timer.unref();\n }\n\n return timer;\n}\n\n/**\n * Wrapper around setInterval which (in node) unrefs the returned timer to avoid\n * wedging the process open unexpectedly.\n * @param {Mixed} args\n * @protected\n * @returns {NodeJS.Timeout|Number}\n */\nexport function safeSetInterval(...args: Parameters<typeof setInterval>): number | NodeJS.Timeout {\n const interval = setInterval(...args);\n\n if (interval.unref) {\n interval.unref();\n }\n\n return interval;\n}\n\n/**\n * Create a restartable timer\n */\nexport class Timer {\n private state: 'init' | 'running' | 'done';\n private readonly timeout: number;\n private readonly callback: () => void;\n private currentTimer: number | NodeJS.Timeout;\n\n /**\n * Construct timer\n * @param {Function} callback Function called when the timer expired\n * @param {number} timeout duration of the timeout in milliseconds\n */\n constructor(callback: () => void, timeout: number) {\n this.state = 'init';\n this.timeout = timeout;\n this.callback = () => {\n this.state = 'done';\n callback();\n };\n }\n\n /**\n * Start timer\n * @returns {void}\n */\n start() {\n if (this.state !== 'init') {\n throw new Error(`Can't start the timer when it's in ${this.state} state`);\n }\n\n this.startTimer();\n this.state = 'running';\n }\n\n /**\n * Clear the current timer and start a new one\n * @returns {void}\n */\n reset() {\n if (this.state !== 'running') {\n throw new Error(`Can't reset the timer when it's in ${this.state} state`);\n }\n this.clearTimer();\n this.startTimer();\n }\n\n /**\n * Clear the timer\n * @returns {void}\n */\n cancel() {\n if (this.state !== 'running') {\n throw new Error(`Can't cancel the timer when it's in ${this.state} state`);\n }\n this.clearTimer();\n this.state = 'done';\n }\n\n /**\n * Create the actual timer\n * @private\n * @returns {undefined}\n */\n private startTimer() {\n this.currentTimer = safeSetTimeout(this.callback, this.timeout);\n }\n\n /**\n * Clear the actual timer\n * @private\n * @returns {undefined}\n */\n private clearTimer() {\n clearTimeout(this.currentTimer);\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAAA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,cAAcA,CAAA,E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U,CAAC,CAAC;MACjB,IAAI,CAACP,KAAK,GAAG,SAAS;IACxB;;IAEA;AACF;AACA;AACA;EAHE;IAAAE,GAAA;IAAAC,KAAA,EAIA,SAAAK,KAAKA,CAAA,EAAG;MACN,IAAI,IAAI,CAACR,KAAK,KAAK,SAAS,EAAE;QAC5B,MAAM,IAAIK,KAAK,uCAAAC,MAAA,CAAuC,IAAI,CAACN,KAAK,WAAQ,CAAC;MAC3E;MACA,IAAI,CAACS,UAAU,CAAC,CAAC;MACjB,IAAI,CAACF,UAAU,CAAC,CAAC;IACnB;;IAEA;AACF;AACA;AACA;EAHE;IAAAL,GAAA;IAAAC,KAAA,EAIA,SAAAO,MAAMA,CAAA,EAAG;MACP,IAAI,IAAI,CAACV,KAAK,KAAK,SAAS,EAAE;QAC5B,MAAM,IAAIK,KAAK,wCAAAC,MAAA,CAAwC,IAAI,CAACN,KAAK,WAAQ,CAAC;MAC5E;MACA,IAAI,CAACS,UAAU,CAAC,CAAC;MACjB,IAAI,CAACT,KAAK,GAAG,MAAM;IACrB;;IAEA;AACF;AACA;AACA;AACA;EAJE;IAAAE,GAAA;IAAAC,KAAA,EAKA,SAAQI,UAAUA,CAAA,EAAG;MACnB,IAAI,CAACI,YAAY,GAAG5B,cAAc,CAAC,IAAI,CAACW,QAAQ,EAAE,IAAI,CAACC,OAAO,CAAC;IACjE;;IAEA;AACF;AACA;AACA;AACA;EAJE;IAAAO,GAAA;IAAAC,KAAA,EAKA,SAAQM,UAAUA,CAAA,EAAG;MACnBG,YAAY,CAAC,IAAI,CAACD,YAAY,CAAC;IACjC;EAAC;AAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -32,12 +32,12 @@
|
|
|
32
32
|
"@webex/eslint-config-legacy": "0.0.0",
|
|
33
33
|
"@webex/jest-config-legacy": "0.0.0",
|
|
34
34
|
"@webex/legacy-tools": "0.0.0",
|
|
35
|
-
"@webex/test-helper-chai": "3.
|
|
36
|
-
"@webex/test-helper-mocha": "3.
|
|
37
|
-
"@webex/test-helper-mock-webex": "3.
|
|
38
|
-
"@webex/test-helper-test-users": "3.
|
|
35
|
+
"@webex/test-helper-chai": "3.11.0",
|
|
36
|
+
"@webex/test-helper-mocha": "3.11.0",
|
|
37
|
+
"@webex/test-helper-mock-webex": "3.11.0",
|
|
38
|
+
"@webex/test-helper-test-users": "3.11.0",
|
|
39
39
|
"eslint": "^8.24.0",
|
|
40
40
|
"prettier": "^2.7.1"
|
|
41
41
|
},
|
|
42
|
-
"version": "3.
|
|
42
|
+
"version": "3.11.0"
|
|
43
43
|
}
|