file-routing-expressjs
Version:
A dependency-free, flexible, system-based file routing for Express.
67 lines • 2.14 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
var async_exports = {};
__export(async_exports, {
withTimeout: () => withTimeout
});
module.exports = __toCommonJS(async_exports);
var import_exceptions = require("../types/exceptions");
function withTimeout(p, ms, abortController) {
return __async(this, null, function* () {
let timeoutId;
const timer = new Promise((_, reject) => {
timeoutId = setTimeout(() => {
if (abortController) {
abortController.abort();
}
reject(new import_exceptions.TimeoutError(ms));
}, ms);
});
try {
return yield Promise.race([p, timer]);
} finally {
clearTimeout(timeoutId);
}
});
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
withTimeout
});
//# sourceMappingURL=async.js.map