Update to v13 and add queue and completely change code
This commit is contained in:
parent
dcef23d0ed
commit
55a38726a3
6706 changed files with 424137 additions and 61608 deletions
43
node_modules/timers-ext/promise_/timeout.js
generated
vendored
Normal file
43
node_modules/timers-ext/promise_/timeout.js
generated
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
"use strict";
|
||||
|
||||
var customError = require("es5-ext/error/custom")
|
||||
, isValue = require("es5-ext/object/is-value")
|
||||
, ensurePromise = require("es5-ext/object/ensure-promise")
|
||||
, nextTick = require("next-tick")
|
||||
, ensureTimeout = require("../valid-timeout");
|
||||
|
||||
module.exports = function (/* timeout */) {
|
||||
ensurePromise(this);
|
||||
var timeout = arguments[0];
|
||||
if (isValue(timeout)) timeout = ensureTimeout(timeout);
|
||||
return new this.constructor(
|
||||
function (resolve, reject) {
|
||||
var isSettled = false, timeoutId;
|
||||
var timeoutCallback = function () {
|
||||
if (isSettled) return;
|
||||
reject(
|
||||
customError(
|
||||
"Operation timeout (exceeded " +
|
||||
(isValue(timeout) ? timeout + "ms" : "tick") +
|
||||
")",
|
||||
"PROMISE_TIMEOUT"
|
||||
)
|
||||
);
|
||||
};
|
||||
if (isValue(timeout)) timeoutId = setTimeout(timeoutCallback, timeout);
|
||||
else nextTick(timeoutCallback);
|
||||
this.then(
|
||||
function (value) {
|
||||
isSettled = true;
|
||||
clearTimeout(timeoutId);
|
||||
resolve(value);
|
||||
},
|
||||
function (reason) {
|
||||
isSettled = true;
|
||||
clearTimeout(timeoutId);
|
||||
reject(reason);
|
||||
}
|
||||
);
|
||||
}.bind(this)
|
||||
);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue