@jcoreio/async-throttle
Advanced tools
Comparing version 1.4.0 to 1.4.1
@@ -13,3 +13,8 @@ "use strict"; | ||
constructor(lastInvocationDone, wait) { | ||
this.effect = new Promise(resolve => this.timeout = setTimeout(resolve, wait)); | ||
this.effect = new Promise((resolve, reject) => { | ||
this.timeout = setTimeout(resolve, wait); | ||
this.resolve = resolve; | ||
this.reject = reject; | ||
}); | ||
this.effect.catch(() => {}); | ||
this.ready = lastInvocationDone.then(() => this.effect); | ||
@@ -20,3 +25,3 @@ } | ||
clearTimeout(this.timeout); | ||
this.effect = undefined; | ||
this.resolve(); | ||
} | ||
@@ -26,4 +31,3 @@ | ||
clearTimeout(this.timeout); | ||
this.effect = Promise.reject(new CanceledError()); | ||
this.effect.catch(() => {}); | ||
this.reject(new CanceledError()); | ||
} | ||
@@ -30,0 +34,0 @@ |
12
index.js
@@ -49,5 +49,8 @@ "use strict"; | ||
(0, _classCallCheck2["default"])(this, Delay); | ||
this.effect = new Promise(function (resolve) { | ||
return _this2.timeout = setTimeout(resolve, wait); | ||
this.effect = new Promise(function (resolve, reject) { | ||
_this2.timeout = setTimeout(resolve, wait); | ||
_this2.resolve = resolve; | ||
_this2.reject = reject; | ||
}); | ||
this.effect["catch"](function () {}); | ||
this.ready = lastInvocationDone.then(function () { | ||
@@ -62,3 +65,3 @@ return _this2.effect; | ||
clearTimeout(this.timeout); | ||
this.effect = undefined; | ||
this.resolve(); | ||
} | ||
@@ -69,4 +72,3 @@ }, { | ||
clearTimeout(this.timeout); | ||
this.effect = Promise.reject(new CanceledError()); | ||
this.effect["catch"](function () {}); | ||
this.reject(new CanceledError()); | ||
} | ||
@@ -73,0 +75,0 @@ }]); |
{ | ||
"name": "@jcoreio/async-throttle", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"description": "throttle async and promise-returning functions. Other packages don't do it right.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
23083
225
0