mirror of
https://github.com/swc-project/swc.git
synced 2024-12-21 04:32:01 +03:00
bbaf619f63
swc_bundler: - [x] Fix wrapped esms. (denoland/deno#9307) - [x] Make test secure.
32 lines
659 B
TypeScript
32 lines
659 B
TypeScript
// Loaded from https://raw.githubusercontent.com/denjucks/dex/master/lib/util/timeout.js
|
|
|
|
|
|
export class KnexTimeoutError extends Error {
|
|
constructor(message) {
|
|
super(message);
|
|
this.name = 'KnexTimeoutError';
|
|
}
|
|
}
|
|
|
|
export function timeout(promise, ms) {
|
|
return new Promise(function (resolve, reject) {
|
|
const id = setTimeout(function () {
|
|
reject(new KnexTimeoutError('operation timed out'));
|
|
}, ms);
|
|
|
|
function wrappedResolve(value) {
|
|
clearTimeout(id);
|
|
resolve(value);
|
|
}
|
|
|
|
function wrappedReject(err) {
|
|
clearTimeout(id);
|
|
reject(err);
|
|
}
|
|
|
|
promise.then(wrappedResolve, wrappedReject);
|
|
});
|
|
}
|
|
|
|
|