Comparing version 3.7.1 to 3.7.2
'use strict'; | ||
const { EventEmitter } = require('node:events'); | ||
const polyfillAbortController = () => { | ||
const emitter = new EventEmitter(); | ||
const signal = { | ||
emitter, | ||
onabort: null, | ||
aborted: false, | ||
reason: undefined, | ||
removeEventListener(name, callback) { | ||
emitter.removeListener(name, callback); | ||
}, | ||
addEventListener(name, callback) { | ||
emitter.on(name, callback); | ||
}, | ||
}; | ||
return { | ||
signal, | ||
abort(reason) { | ||
if (signal.aborted) return; | ||
signal.aborted = true; | ||
signal.reason = reason ? reason : new Error('AbortError'); | ||
const event = { type: 'abort', target: signal }; | ||
if (signal.onabort) signal.onabort(event); | ||
emitter.emit(event.type, event); | ||
}, | ||
}; | ||
}; | ||
const nativeAbortController = () => new AbortController(); | ||
const createAbortController = global.AbortController | ||
? nativeAbortController | ||
: polyfillAbortController; | ||
const timeout = (msec, signal = null) => | ||
@@ -61,5 +26,4 @@ new Promise((resolve, reject) => { | ||
module.exports = { | ||
createAbortController, | ||
timeout, | ||
delay, | ||
}; |
{ | ||
"name": "metautil", | ||
"version": "3.7.1", | ||
"version": "3.7.2", | ||
"author": "Timur Shemsedinov <timur.shemsedinov@gmail.com>", | ||
"license": "MIT", | ||
"description": "Metarhia utilities", | ||
"keywords": ["node.js", "metarhia", "util"], | ||
"keywords": [ | ||
"node.js", | ||
"metarhia", | ||
"util" | ||
], | ||
"main": "metautil.js", | ||
"types": "metautil.d.ts", | ||
"files": ["lib/", "metautil.d.ts"], | ||
"files": [ | ||
"lib/", | ||
"metautil.d.ts" | ||
], | ||
"engines": { | ||
"node": "^14.18 || 16 || 18 || 19" | ||
"node": "16 || 18 || 19 || 20" | ||
}, | ||
@@ -42,4 +49,4 @@ "repository": { | ||
"prettier": "^2.8.4", | ||
"typescript": "^4.9.5" | ||
"typescript": "^5.0.4" | ||
} | ||
} |
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
30723
11
829