Comparing version 3.3.0 to 3.4.0
@@ -5,2 +5,7 @@ # Changelog | ||
## [3.4.0][] - 2021-02-21 | ||
- Implement simple polyfill for AbortController | ||
- Support AbortController in `await timeout` | ||
## [3.3.0][] - 2021-02-19 | ||
@@ -38,3 +43,4 @@ | ||
[unreleased]: https://github.com/metarhia/metautil/compare/v3.3.0...HEAD | ||
[unreleased]: https://github.com/metarhia/metautil/compare/v3.4.0...HEAD | ||
[3.4.0]: https://github.com/metarhia/metautil/compare/v3.3.0...v3.4.0 | ||
[3.3.0]: https://github.com/metarhia/metautil/compare/v3.2.0...v3.3.0 | ||
@@ -41,0 +47,0 @@ [3.2.0]: https://github.com/metarhia/metautil/compare/v3.1.0...v3.2.0 |
'use strict'; | ||
const path = require('path'); | ||
const { EventEmitter } = require('events'); | ||
@@ -144,5 +145,18 @@ const random = (min, max) => { | ||
const timeout = (msec) => | ||
new Promise((resolve) => { | ||
setTimeout(resolve, msec); | ||
const createAbortController = () => { | ||
const signal = new EventEmitter(); | ||
const abort = () => { | ||
signal.emit('abort'); | ||
}; | ||
return { abort, signal }; | ||
}; | ||
const timeout = (msec, signal = null) => | ||
new Promise((resolve, reject) => { | ||
const timer = setTimeout(resolve, msec); | ||
if (!signal) return; | ||
signal.on('abort', () => { | ||
clearTimeout(timer); | ||
reject(); | ||
}); | ||
}); | ||
@@ -165,3 +179,4 @@ | ||
parseCookies, | ||
createAbortController, | ||
timeout, | ||
}; |
{ | ||
"name": "metautil", | ||
"version": "3.3.0", | ||
"version": "3.4.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
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
13314
314
0