Comparing version 3.4.0 to 3.5.0
@@ -5,2 +5,8 @@ # Changelog | ||
## [3.5.0][] - 2021-02-22 | ||
- Implemented `await delay(msec, signal)` | ||
- Fix timeout behaviour to reject promise (throw) | ||
- Generate errors on timeout and on abort timeout | ||
## [3.4.0][] - 2021-02-21 | ||
@@ -43,3 +49,4 @@ | ||
[unreleased]: https://github.com/metarhia/metautil/compare/v3.4.0...HEAD | ||
[unreleased]: https://github.com/metarhia/metautil/compare/v3.5.0...HEAD | ||
[3.5.0]: https://github.com/metarhia/metautil/compare/v3.4.0...v3.5.0 | ||
[3.4.0]: https://github.com/metarhia/metautil/compare/v3.3.0...v3.4.0 | ||
@@ -46,0 +53,0 @@ [3.3.0]: https://github.com/metarhia/metautil/compare/v3.2.0...v3.3.0 |
@@ -155,2 +155,14 @@ 'use strict'; | ||
new Promise((resolve, reject) => { | ||
const timer = setTimeout(() => { | ||
reject(new Error('Timeout reached')); | ||
}, msec); | ||
if (!signal) return; | ||
signal.on('abort', () => { | ||
clearTimeout(timer); | ||
reject(new Error('Timeout aborted')); | ||
}); | ||
}); | ||
const delay = (msec, signal = null) => | ||
new Promise((resolve, reject) => { | ||
const timer = setTimeout(resolve, msec); | ||
@@ -160,3 +172,3 @@ if (!signal) return; | ||
clearTimeout(timer); | ||
reject(); | ||
reject(new Error('Delay aborted')); | ||
}); | ||
@@ -182,2 +194,3 @@ }); | ||
timeout, | ||
delay, | ||
}; |
{ | ||
"name": "metautil", | ||
"version": "3.4.0", | ||
"version": "3.5.0", | ||
"author": "Timur Shemsedinov <timur.shemsedinov@gmail.com>", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
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
13902
326