Innovenergy_trunk/frontend/node_modules/testcafe/lib/utils/execute-fn-with-timeout.js

18 lines
2.2 KiB
JavaScript
Raw Permalink Normal View History

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const time_limit_promise_1 = __importDefault(require("time-limit-promise"));
// This function can finish with reject
function executeFnWithTimeout(fn, timeout, ...args) {
if (!timeout)
return fn(...args);
else if (!timeout.timeout)
throw timeout.rejectWith;
else
return (0, time_limit_promise_1.default)(fn(...args), timeout.timeout, { rejectWith: timeout.rejectWith });
}
exports.default = executeFnWithTimeout;
module.exports = exports.default;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXhlY3V0ZS1mbi13aXRoLXRpbWVvdXQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdXRpbHMvZXhlY3V0ZS1mbi13aXRoLXRpbWVvdXQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7QUFBQSw0RUFBMkM7QUFRM0MsdUNBQXVDO0FBQ3ZDLFNBQXdCLG9CQUFvQixDQUFFLEVBQVksRUFBRSxPQUFnQyxFQUFFLEdBQUcsSUFBVztJQUN4RyxJQUFJLENBQUMsT0FBTztRQUNSLE9BQU8sRUFBRSxDQUFDLEdBQUcsSUFBSSxDQUFDLENBQUM7U0FDbEIsSUFBSSxDQUFDLE9BQU8sQ0FBQyxPQUFPO1FBQ3JCLE1BQU0sT0FBTyxDQUFDLFVBQVUsQ0FBQzs7UUFFekIsT0FBTyxJQUFBLDRCQUFTLEVBQUMsRUFBRSxDQUFDLEdBQUcsSUFBSSxDQUFDLEVBQUUsT0FBTyxDQUFDLE9BQU8sRUFBRSxFQUFFLFVBQVUsRUFBRSxPQUFPLENBQUMsVUFBVSxFQUFFLENBQUMsQ0FBQztBQUMzRixDQUFDO0FBUEQsdUNBT0MiLC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