Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

promise-toolbox

Package Overview
Dependencies
Maintainers
3
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

promise-toolbox - npm Package Compare versions

Comparing version 0.19.2 to 0.20.0

6

_evalDisposable.js
"use strict";
var pTry = require("./try");
const pTry = require("./try");
module.exports = function (v) {
return typeof v === "function" ? pTry(v) : Promise.resolve(v);
};
module.exports = v => typeof v === "function" ? pTry(v) : Promise.resolve(v);
"use strict";
var isDisposable = require("./_isDisposable");
const isDisposable = require("./_isDisposable");
var resolve = require("./_resolve");
const resolve = require("./_resolve");
module.exports = function () {
function ExitStack() {
var _this = this;
module.exports = class ExitStack {
constructor() {
this._disposables = [];
var dispose = function dispose() {
var disposable = _this._disposables.pop();
const dispose = () => {
const disposable = this._disposables.pop();

@@ -25,5 +23,3 @@ return disposable !== undefined ? resolve(disposable.dispose()).then(dispose) : Promise.resolve();

var _proto = ExitStack.prototype;
_proto.enter = function enter(disposable) {
enter(disposable) {
if (!isDisposable(disposable)) {

@@ -36,5 +32,4 @@ throw new TypeError("not a disposable");

return disposable.value;
};
}
return ExitStack;
}();
};
"use strict";
var pFinally = function pFinally(p, cb) {
return p.then(cb, cb).then(function () {
return p;
});
};
const pFinally = (p, cb) => p.then(cb, cb).then(() => p);
module.exports = pFinally;
"use strict";
module.exports = function (value) {
return value;
};
module.exports = value => value;
"use strict";
module.exports = function (v) {
return v != null && typeof v.dispose === "function";
};
module.exports = v => v != null && typeof v.dispose === "function";
"use strict";
module.exports = function (reason) {
return reason instanceof ReferenceError || reason instanceof SyntaxError || reason instanceof TypeError;
};
module.exports = reason => reason instanceof ReferenceError || reason instanceof SyntaxError || reason instanceof TypeError;
"use strict";
var noop = require("./_noop");
const noop = require("./_noop");
var once = require("./_once");
const once = require("./_once");
module.exports = function ($cancelToken, emitter, arrayArg) {
var add = emitter.addEventListener || emitter.addListener || emitter.on;
module.exports = ($cancelToken, emitter, arrayArg) => {
const add = emitter.addEventListener || emitter.addListener || emitter.on;

@@ -14,9 +14,9 @@ if (add === undefined) {

var remove = emitter.removeEventListener || emitter.removeListener || emitter.off;
var eventsAndListeners = [];
var clean = noop;
const remove = emitter.removeEventListener || emitter.removeListener || emitter.off;
const eventsAndListeners = [];
let clean = noop;
if (remove !== undefined) {
clean = once(function () {
for (var i = 0, n = eventsAndListeners.length; i < n; i += 2) {
clean = once(() => {
for (let i = 0, n = eventsAndListeners.length; i < n; i += 2) {
remove.call(emitter, eventsAndListeners[i], eventsAndListeners[i + 1]);

@@ -28,6 +28,6 @@ }

return arrayArg ? function (eventName, cb) {
return arrayArg ? (eventName, cb) => {
function listener() {
clean();
var event = Array.prototype.slice.call(arguments);
const event = Array.prototype.slice.call(arguments);
event.args = event;

@@ -40,4 +40,4 @@ event.event = event.name = eventName;

add.call(emitter, eventName, listener);
} : function (event, cb) {
var listener = function listener(arg) {
} : (event, cb) => {
const listener = arg => {
clean();

@@ -44,0 +44,0 @@ cb(arg);

"use strict";
var isProgrammerError = require("./_isProgrammerError");
const isProgrammerError = require("./_isProgrammerError");

@@ -10,3 +10,3 @@ module.exports = function matchError(predicate, error) {

var type = typeof predicate;
const type = typeof predicate;

@@ -22,5 +22,5 @@ if (type === "boolean") {

if (Array.isArray(predicate)) {
var n = predicate.length;
const n = predicate.length;
for (var i = 0; i < n; ++i) {
for (let i = 0; i < n; ++i) {
if (matchError(predicate[i], error)) {

@@ -35,3 +35,3 @@ return true;

if (error != null && type === "object") {
for (var key in predicate) {
for (const key in predicate) {
if (hasOwnProperty.call(predicate, key) && error[key] !== predicate[key]) {

@@ -38,0 +38,0 @@ return false;

"use strict";
module.exports = function (fn) {
var result;
module.exports = fn => {
let result;
return function () {

@@ -6,0 +6,0 @@ if (fn !== undefined) {

"use strict";
var isPromise = require("./isPromise");
const isPromise = require("./isPromise");
module.exports = function (value) {
return isPromise(value) ? value : Promise.resolve(value);
};
module.exports = value => isPromise(value) ? value : Promise.resolve(value);
"use strict";
module.exports = function () {
var _defineProperties = Object.defineProperties;
module.exports = (() => {
const _defineProperties = Object.defineProperties;
try {
var f = _defineProperties(function () {}, {
const f = _defineProperties(function () {}, {
length: {

@@ -17,14 +17,12 @@ value: 2

if (f.length === 2 && f.name === "foo") {
return function (fn, name, length) {
return _defineProperties(fn, {
length: {
configurable: true,
value: length > 0 ? length : 0
},
name: {
configurable: true,
value: name
}
});
};
return (fn, name, length) => _defineProperties(fn, {
length: {
configurable: true,
value: length > 0 ? length : 0
},
name: {
configurable: true,
value: name
}
});
}

@@ -34,2 +32,2 @@ } catch (_) {}

return require("./_identity");
}();
})();
"use strict";
var getSymbol = typeof Symbol === "function" ? function (name) {
var symbol = Symbol[name];
const getSymbol = typeof Symbol === "function" ? name => {
const symbol = Symbol[name];
return symbol !== undefined ? symbol : `@@${name}`;
} : function (name) {
return `@@${name}`;
};
} : name => `@@${name}`;
exports.$$iterator = getSymbol("iterator");
exports.$$toStringTag = getSymbol("toStringTag");

@@ -7,11 +7,11 @@ "use strict";

var isPromise = require("./isPromise");
const isPromise = require("./isPromise");
var _require = require("./_symbols"),
$$iterator = _require.$$iterator;
const _require = require("./_symbols"),
$$iterator = _require.$$iterator;
var forArray = exports.forArray = function (array, iteratee) {
var length = array.length;
const forArray = exports.forArray = (array, iteratee) => {
const length = array.length;
for (var i = 0; i < length; ++i) {
for (let i = 0; i < length; ++i) {
iteratee(array[i], i, array);

@@ -21,4 +21,4 @@ }

exports.forIn = function (object, iteratee) {
for (var key in object) {
exports.forIn = (object, iteratee) => {
for (const key in object) {
iteratee(object[key], key, object);

@@ -28,5 +28,5 @@ }

var forIterable = exports.forIterable = function (iterable, iteratee) {
var iterator = iterable[$$iterator]();
var current;
const forIterable = exports.forIterable = (iterable, iteratee) => {
const iterator = iterable[$$iterator]();
let current;

@@ -38,6 +38,6 @@ while (!(current = iterator.next()).done) {

var hasOwnProperty = Object.prototype.hasOwnProperty;
const hasOwnProperty = Object.prototype.hasOwnProperty;
var forOwn = exports.forOwn = function (object, iteratee) {
for (var key in object) {
const forOwn = exports.forOwn = (object, iteratee) => {
for (const key in object) {
if (hasOwnProperty.call(object, key)) {

@@ -49,35 +49,19 @@ iteratee(object[key], key, object);

var isIterable = function isIterable(value) {
return value != null && typeof value[$$iterator] === "function";
};
const isIterable = value => value != null && typeof value[$$iterator] === "function";
var forEach = exports.forEach = function (collection, iteratee) {
return Array.isArray(collection) ? forArray(collection, iteratee) : isIterable(collection) ? forIterable(collection, iteratee) : isArrayLike(collection) ? forArray(collection, iteratee) : forOwn(collection, iteratee);
};
const forEach = exports.forEach = (collection, iteratee) => Array.isArray(collection) ? forArray(collection, iteratee) : isIterable(collection) ? forIterable(collection, iteratee) : isArrayLike(collection) ? forArray(collection, iteratee) : forOwn(collection, iteratee);
var isLength = function isLength(value) {
return typeof value === "number" && value >= 0 && value < Infinity && Math.floor(value) === value;
};
const isLength = value => typeof value === "number" && value >= 0 && value < Infinity && Math.floor(value) === value;
var isArrayLike = exports.isArrayLike = function (value) {
return typeof value !== "function" && value != null && isLength(value.length);
};
const isArrayLike = exports.isArrayLike = value => typeof value !== "function" && value != null && isLength(value.length);
exports.makeAsyncIterator = function (iterator) {
var asyncIterator = function asyncIterator(collection, iteratee) {
exports.makeAsyncIterator = iterator => {
const asyncIterator = (collection, iteratee) => {
if (isPromise(collection)) {
return collection.then(function (collection) {
return asyncIterator(collection, iteratee);
});
return collection.then(collection => asyncIterator(collection, iteratee));
}
var mainPromise = Promise.resolve();
iterator(collection, function (value, key) {
mainPromise = isPromise(value) ? mainPromise.then(function () {
return value.then(function (value) {
return iteratee(value, key, collection);
});
}) : mainPromise.then(function () {
return iteratee(value, key, collection);
});
let mainPromise = Promise.resolve();
iterator(collection, (value, key) => {
mainPromise = isPromise(value) ? mainPromise.then(() => value.then(value => iteratee(value, key, collection))) : mainPromise.then(() => iteratee(value, key, collection));
});

@@ -90,5 +74,5 @@ return mainPromise;

exports.map = function (collection, iteratee) {
var result = [];
forEach(collection, function (item, key, collection) {
exports.map = (collection, iteratee) => {
const result = [];
forEach(collection, (item, key, collection) => {
result.push(iteratee(item, key, collection));

@@ -99,7 +83,7 @@ });

exports.mapAuto = function (collection, iteratee) {
var result = isArrayLike(collection) ? new Array(collection.length) : Object.create(null);
exports.mapAuto = (collection, iteratee) => {
const result = isArrayLike(collection) ? new Array(collection.length) : Object.create(null);
if (iteratee !== undefined) {
forEach(collection, function (item, key, collection) {
forEach(collection, (item, key, collection) => {
result[key] = iteratee(item, key, collection);

@@ -106,0 +90,0 @@ });

@@ -5,5 +5,3 @@ "use strict";

if (typeof cb === "function") {
this.then(function (value) {
return cb(undefined, value);
}, cb);
this.then(value => cb(undefined, value), cb);
}

@@ -10,0 +8,0 @@

"use strict";
var identity = require("./_identity");
const identity = require("./_identity");
var isPromise = require("./isPromise");
const isPromise = require("./isPromise");
var toPromise = require("./_resolve");
const toPromise = require("./_resolve");
var noop = Function.prototype;
const noop = Function.prototype;
function step(key, value) {
var cursor;
let cursor;

@@ -43,24 +43,15 @@ try {

var asyncFn = function asyncFn(generator) {
return function () {
var _arguments = arguments,
_this = this;
return new Promise(function (resolve, reject) {
return new AsyncFn(generator.apply(_this, _arguments), resolve, reject).next();
});
};
const asyncFn = generator => function () {
return new Promise((resolve, reject) => new AsyncFn(generator.apply(this, arguments), resolve, reject).next());
};
function CancelabledAsyncFn(cancelToken) {
var _this2 = this;
AsyncFn.apply(this, [].slice.call(arguments, 1));
this._cancelToken = cancelToken;
this._onCancel = noop;
this.finally = cancelToken.addHandler(function (reason) {
_this2._onCancel(reason);
this.finally = cancelToken.addHandler(reason => {
this._onCancel(reason);
return new Promise(function (resolve) {
_this2.finally = resolve;
return new Promise(resolve => {
this.finally = resolve;
});

@@ -71,4 +62,2 @@ });

Object.setPrototypeOf(CancelabledAsyncFn.prototype, Object.getPrototypeOf(AsyncFn.prototype)).toPromise = function (value) {
var _this3 = this;
if (Array.isArray(value)) {

@@ -78,3 +67,3 @@ return toPromise(value[0]);

var cancelToken = this._cancelToken;
const cancelToken = this._cancelToken;

@@ -85,29 +74,20 @@ if (cancelToken.requested) {

return isPromise(value) ? new Promise(function (resolve, reject) {
return isPromise(value) ? new Promise((resolve, reject) => {
value.then(resolve, reject);
_this3._onCancel = reject;
this._onCancel = reject;
}) : Promise.resolve(value);
};
asyncFn.cancelable = function (generator, getCancelToken) {
if (getCancelToken === void 0) {
getCancelToken = identity;
asyncFn.cancelable = (generator, getCancelToken = identity) => function () {
const cancelToken = getCancelToken.apply(this, arguments);
if (cancelToken.requested) {
return Promise.reject(cancelToken.reason);
}
return function () {
var _arguments2 = arguments,
_this4 = this;
var cancelToken = getCancelToken.apply(this, arguments);
if (cancelToken.requested) {
return Promise.reject(cancelToken.reason);
}
return new Promise(function (resolve, reject) {
new CancelabledAsyncFn(cancelToken, generator.apply(_this4, _arguments2), resolve, reject).next();
});
};
return new Promise((resolve, reject) => {
new CancelabledAsyncFn(cancelToken, generator.apply(this, arguments), resolve, reject).next();
});
};
module.exports = asyncFn;
"use strict";
module.exports = function () {
function Cancel(message) {
if (message === void 0) {
message = "this action has been canceled";
}
module.exports = class Cancel {
constructor(message = "this action has been canceled") {
Object.defineProperty(this, "message", {

@@ -15,9 +11,6 @@ enumerable: true,

var _proto = Cancel.prototype;
_proto.toString = function toString() {
toString() {
return `Cancel: ${this.message}`;
};
}
return Cancel;
}();
};
"use strict";
var setFunctionNameAndLength = require("./_setFunctionNameAndLength");
const setFunctionNameAndLength = require("./_setFunctionNameAndLength");
var _require = require("./CancelToken"),
isCancelToken = _require.isCancelToken,
source = _require.source;
const _require = require("./CancelToken"),
isCancelToken = _require.isCancelToken,
source = _require.source;
var cancelable = function cancelable(target, name, descriptor) {
var fn = descriptor !== undefined ? descriptor.value : target;
var wrapper = setFunctionNameAndLength(function cancelableWrapper() {
var length = arguments.length;
const cancelable = (target, name, descriptor) => {
const fn = descriptor !== undefined ? descriptor.value : target;
const wrapper = setFunctionNameAndLength(function cancelableWrapper() {
const length = arguments.length;

@@ -18,14 +18,14 @@ if (length !== 0 && isCancelToken(arguments[0])) {

var _source = source(),
cancel = _source.cancel,
token = _source.token;
const _source = source(),
cancel = _source.cancel,
token = _source.token;
var args = new Array(length + 1);
const args = new Array(length + 1);
args[0] = token;
for (var i = 0; i < length; ++i) {
for (let i = 0; i < length; ++i) {
args[i + 1] = arguments[i];
}
var promise = fn.apply(this, args);
const promise = fn.apply(this, args);
promise.cancel = cancel;

@@ -32,0 +32,0 @@ return promise;

"use strict";
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
const defer = require("./defer");
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
const Cancel = require("./Cancel");
var defer = require("./defer");
const isPromise = require("./isPromise");
var Cancel = require("./Cancel");
const noop = require("./_noop");
var isPromise = require("./isPromise");
const _require = require("./_symbols"),
$$toStringTag = _require.$$toStringTag;
var noop = require("./_noop");
const cancelTokenTag = "CancelToken";
var _require = require("./_symbols"),
$$toStringTag = _require.$$toStringTag;
var cancelTokenTag = "CancelToken";
function cancel(message) {

@@ -25,4 +21,4 @@ if (this._reason !== undefined) {

var reason = this._reason = message instanceof Cancel ? message : new Cancel(message);
var resolve = this._resolve;
const reason = this._reason = message instanceof Cancel ? message : new Cancel(message);
const resolve = this._resolve;

@@ -34,3 +30,3 @@ if (resolve !== undefined) {

var onabort = this.onabort;
const onabort = this.onabort;

@@ -41,3 +37,3 @@ if (typeof onabort === "function") {

var handlers = this._handlers;
const handlers = this._handlers;

@@ -47,17 +43,17 @@ if (handlers !== undefined) {

var _defer = defer(),
promise = _defer.promise,
_resolve = _defer.resolve;
const _defer = defer(),
promise = _defer.promise,
resolve = _defer.resolve;
var wait = 0;
let wait = 0;
var onSettle = function onSettle() {
const onSettle = () => {
if (--wait === 0) {
return _resolve();
return resolve();
}
};
for (var i = 0, n = handlers.length; i < n; ++i) {
for (let i = 0, n = handlers.length; i < n; ++i) {
try {
var result = handlers[i](reason);
const result = handlers[i](reason);

@@ -78,6 +74,6 @@ if (isPromise(result)) {

function removeHandler(handler) {
var handlers = this._handlers;
const handlers = this._handlers;
if (handlers !== undefined) {
var i = handlers.indexOf(handler);
const i = handlers.indexOf(handler);

@@ -90,6 +86,6 @@ if (i !== -1) {

var INTERNAL = {};
const INTERNAL = {};
function CancelTokenSource(tokens) {
var cancel_ = this.cancel = cancel.bind(this.token = new CancelToken(INTERNAL));
const cancel_ = this.cancel = cancel.bind(this.token = new CancelToken(INTERNAL));

@@ -100,4 +96,4 @@ if (tokens == null) {

tokens.forEach(function (token) {
var reason = token.reason;
tokens.forEach(token => {
const reason = token.reason;

@@ -113,4 +109,4 @@ if (reason !== undefined) {

var CancelToken = function () {
CancelToken.from = function from(abortSignal) {
class CancelToken {
static from(abortSignal) {
if (CancelToken.isCancelToken(abortSignal)) {

@@ -120,16 +116,16 @@ return abortSignal;

var token = new CancelToken(INTERNAL);
const token = new CancelToken(INTERNAL);
abortSignal.addEventListener("abort", cancel.bind(token));
return token;
};
}
CancelToken.isCancelToken = function isCancelToken(value) {
static isCancelToken(value) {
return value != null && value[$$toStringTag] === cancelTokenTag;
};
}
CancelToken.source = function source(tokens) {
static source(tokens) {
return new CancelTokenSource(tokens);
};
}
function CancelToken(executor) {
constructor(executor) {
this._handlers = undefined;

@@ -146,7 +142,26 @@ this._promise = undefined;

var _proto = CancelToken.prototype;
get promise() {
let promise = this._promise;
_proto.addHandler = function addHandler(handler) {
var handlers = this._handlers;
if (promise === undefined) {
const reason = this._reason;
promise = this._promise = reason !== undefined ? Promise.resolve(reason) : new Promise(resolve => {
this._resolve = resolve;
});
}
return promise;
}
get reason() {
return this._reason;
}
get requested() {
return this._reason !== undefined;
}
addHandler(handler) {
let handlers = this._handlers;
if (handlers === undefined) {

@@ -162,6 +177,6 @@ if (this.requested) {

return removeHandler.bind(this, handler);
};
}
_proto.throwIfRequested = function throwIfRequested() {
var reason = this._reason;
throwIfRequested() {
const reason = this._reason;

@@ -171,5 +186,13 @@ if (reason !== undefined) {

}
};
}
_proto.addEventListener = function addEventListener(type, listener) {
get [$$toStringTag]() {
return cancelTokenTag;
}
get aborted() {
return this.requested;
}
addEventListener(type, listener) {
if (type !== "abort") {

@@ -179,15 +202,11 @@ return;

var event = {
const event = {
type: "abort"
};
var handler = typeof listener === "function" ? function () {
return listener(event);
} : function () {
return listener.handleEvent(event);
};
const handler = typeof listener === "function" ? () => listener(event) : () => listener.handleEvent(event);
handler.listener = listener;
this.addHandler(handler);
};
}
_proto.removeEventListener = function removeEventListener(type, listener) {
removeEventListener(type, listener) {
if (type !== "abort") {

@@ -197,8 +216,6 @@ return;

var handlers = this._handlers;
const handlers = this._handlers;
if (handlers !== undefined) {
var i = handlers.findIndex(function (handler) {
return handler.listener === listener;
});
const i = handlers.findIndex(handler => handler.listener === listener);

@@ -209,45 +226,6 @@ if (i !== -1) {

}
};
}
_createClass(CancelToken, [{
key: "promise",
get: function get() {
var _this = this;
}
var promise = this._promise;
if (promise === undefined) {
var reason = this._reason;
promise = this._promise = reason !== undefined ? Promise.resolve(reason) : new Promise(function (resolve) {
_this._resolve = resolve;
});
}
return promise;
}
}, {
key: "reason",
get: function get() {
return this._reason;
}
}, {
key: "requested",
get: function get() {
return this._reason !== undefined;
}
}, {
key: $$toStringTag,
get: function get() {
return cancelTokenTag;
}
}, {
key: "aborted",
get: function get() {
return this.requested;
}
}]);
return CancelToken;
}();
cancel.call(CancelToken.canceled = new CancelToken(INTERNAL));

@@ -254,0 +232,0 @@ CancelToken.none = new CancelToken(INTERNAL);

"use strict";
var matchError = require("./_matchError");
const matchError = require("./_matchError");

@@ -10,4 +10,4 @@ function handler(predicates, cb, reason) {

module.exports = function pCatch() {
var n = arguments.length;
var cb;
let n = arguments.length;
let cb;

@@ -14,0 +14,0 @@ if (n === 0 || typeof (cb = arguments[--n]) !== "function") {

"use strict";
var defer = function defer() {
var resolve, reject;
var promise = new Promise(function (resolve_, reject_) {
const defer = () => {
let resolve, reject;
const promise = new Promise((resolve_, reject_) => {
resolve = resolve_;

@@ -7,0 +7,0 @@ reject = reject_;

"use strict";
var isPromise = require("./isPromise");
const isPromise = require("./isPromise");
module.exports = function delay(ms) {
var value = arguments.length === 2 ? arguments[1] : this;
const value = arguments.length === 2 ? arguments[1] : this;
if (isPromise(value)) {
return value.then(function (value) {
return new Promise(function (resolve) {
setTimeout(resolve, ms, value);
});
});
return value.then(value => new Promise(resolve => {
setTimeout(resolve, ms, value);
}));
}
var handle;
var p = new Promise(function (resolve) {
let handle;
const p = new Promise(resolve => {
handle = setTimeout(resolve, ms, value);
});
p.unref = function () {
p.unref = () => {
if (handle != null && typeof handle.unref === "function") {

@@ -23,0 +21,0 @@ handle.unref();

"use strict";
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
const evalDisposable = require("./_evalDisposable");
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
const isDisposable = require("./_isDisposable");
var evalDisposable = require("./_evalDisposable");
const pFinally = require("./_finally");
var isDisposable = require("./_isDisposable");
const setFunctionNameAndLength = require("./_setFunctionNameAndLength");
var pFinally = require("./_finally");
const wrapApply = require("./wrapApply");
var setFunctionNameAndLength = require("./_setFunctionNameAndLength");
const wrapCall = require("./wrapCall");
var wrapApply = require("./wrapApply");
var wrapCall = require("./wrapCall");
var Disposable = function () {
function Disposable(dispose, value) {
class Disposable {
constructor(dispose, value) {
if (typeof dispose !== "function") {

@@ -29,5 +25,11 @@ throw new Error("dispose must be a function");

var _proto = Disposable.prototype;
get value() {
if (this._dispose === undefined) {
throw new TypeError("this disposable has already been disposed");
}
_proto.dispose = function dispose() {
return this._value;
}
dispose() {
if (this._dispose === undefined) {

@@ -37,35 +39,21 @@ throw new TypeError("this disposable has already been disposed");

var d = this._dispose;
const d = this._dispose;
this._dispose = this._value = undefined;
return d();
};
}
_createClass(Disposable, [{
key: "value",
get: function get() {
if (this._dispose === undefined) {
throw new TypeError("this disposable has already been disposed");
}
}
return this._value;
}
}]);
return Disposable;
}();
module.exports = Disposable;
Disposable.all = function all(iterable) {
var disposables = [];
let disposables = [];
var dispose = function dispose() {
var d = disposables;
const dispose = () => {
const d = disposables;
disposables = undefined;
d.forEach(function (disposable) {
return disposable.dispose();
});
d.forEach(disposable => disposable.dispose());
};
var onFulfill = function onFulfill(maybeDisposable) {
const onFulfill = maybeDisposable => {
if (disposables === undefined) {

@@ -83,3 +71,3 @@ return isDisposable(maybeDisposable) && maybeDisposable.dispose();

var onReject = function onReject(error) {
const onReject = error => {
if (disposables === undefined) {

@@ -93,63 +81,42 @@ return;

return Promise.all(Array.from(iterable, function (maybeDisposable) {
return evalDisposable(maybeDisposable).then(onFulfill, onReject);
})).then(function (values) {
return new Disposable(dispose, values);
});
return Promise.all(Array.from(iterable, maybeDisposable => evalDisposable(maybeDisposable).then(onFulfill, onReject))).then(values => new Disposable(dispose, values));
};
var ExitStack = require("./_ExitStack");
const ExitStack = require("./_ExitStack");
Disposable.factory = function (genFn) {
return setFunctionNameAndLength(function () {
var gen = genFn.apply(this, arguments);
Disposable.factory = genFn => setFunctionNameAndLength(function () {
const gen = genFn.apply(this, arguments);
var _ExitStack = new ExitStack(),
const _ExitStack = new ExitStack(),
dispose = _ExitStack.dispose,
stack = _ExitStack.value;
var onEvalDisposable = function onEvalDisposable(value) {
return isDisposable(value) ? loop(stack.enter(value)) : value;
};
const onEvalDisposable = value => isDisposable(value) ? loop(stack.enter(value)) : value;
var onFulfill = function onFulfill(_ref) {
var value = _ref.value;
return evalDisposable(value).then(onEvalDisposable);
};
const onFulfill = ({
value
}) => evalDisposable(value).then(onEvalDisposable);
var loop = function loop(value) {
return wrapCall(gen.next, value, gen).then(onFulfill);
const loop = value => wrapCall(gen.next, value, gen).then(onFulfill);
return loop().then(value => new Disposable(() => wrapCall(gen.return, undefined, gen).then(dispose), value), error => {
const forwardError = () => {
throw error;
};
return loop().then(function (value) {
return new Disposable(function () {
return wrapCall(gen.return, undefined, gen).then(dispose);
}, value);
}, function (error) {
var forwardError = function forwardError() {
throw error;
};
return dispose().then(forwardError, forwardError);
});
}, genFn.name, genFn.length);
return dispose().then(forwardError, forwardError);
});
}, genFn.name, genFn.length);
};
const onHandlerFulfill = result => {
const _ExitStack2 = new ExitStack(),
dispose = _ExitStack2.dispose,
stack = _ExitStack2.value;
var onHandlerFulfill = function onHandlerFulfill(result) {
var _ExitStack2 = new ExitStack(),
dispose = _ExitStack2.dispose,
stack = _ExitStack2.value;
const onEvalDisposable = disposable => loop(stack.enter(disposable));
var onEvalDisposable = function onEvalDisposable(disposable) {
return loop(stack.enter(disposable));
};
const onFulfill = cursor => cursor.done ? cursor.value : evalDisposable(cursor.value).then(onEvalDisposable);
var onFulfill = function onFulfill(cursor) {
return cursor.done ? cursor.value : evalDisposable(cursor.value).then(onEvalDisposable);
};
const loop = value => wrapCall(result.next, value, result).then(onFulfill);
var loop = function loop(value) {
return wrapCall(result.next, value, result).then(onFulfill);
};
return pFinally(loop(), dispose);

@@ -159,6 +126,4 @@ };

Disposable.use = function use() {
var _this = this;
let nDisposables = arguments.length - 1;
var nDisposables = arguments.length - 1;
if (nDisposables < 0) {

@@ -168,12 +133,10 @@ throw new TypeError("Disposable.use expects at least 1 argument");

var handler = arguments[nDisposables];
const handler = arguments[nDisposables];
if (nDisposables === 0) {
return new Promise(function (resolve) {
return resolve(handler.call(_this));
}).then(onHandlerFulfill);
return new Promise(resolve => resolve(handler.call(this))).then(onHandlerFulfill);
}
var disposables;
var spread = !Array.isArray(disposables = arguments[0]);
let disposables;
const spread = !Array.isArray(disposables = arguments[0]);

@@ -186,7 +149,7 @@ if (spread) {

return Disposable.all(disposables).then(function (dAll) {
return pFinally((spread ? wrapApply : wrapCall)(handler, dAll.value, _this), function () {
return dAll.dispose();
});
});
return Disposable.all(disposables).then(dAll => pFinally((spread ? wrapApply : wrapCall)(handler, dAll.value, this), () => dAll.dispose()));
};
Disposable.wrap = generator => function () {
return Disposable.use(() => generator.apply(this, arguments));
};
"use strict";
module.exports = function pFinally(cb) {
var _this = this;
return this.then(cb, cb).then(function () {
return _this;
});
return this.then(cb, cb).then(() => this);
};
"use strict";
exports.hideLiteralErrorFromLinter = function (literal) {
return literal;
};
exports.hideLiteralErrorFromLinter = literal => literal;
exports.reject = function (reason) {
return Promise.reject(reason);
};
exports.reject = reason => Promise.reject(reason);
exports.throwArg = function (value) {
exports.throwArg = value => {
throw value;
};
"use strict";
function resolver(fn, args, resolve, reject) {
args.push(function (error, result) {
return error != null && error !== false ? reject(error) : resolve(result);
});
args.push((error, result) => error != null && error !== false ? reject(error) : resolve(result));
fn.apply(this, args);
}
module.exports = function fromCallback(fn) {
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
module.exports = function fromCallback(fn, ...args) {
return new Promise(resolver.bind(this, typeof fn === "function" ? fn : this[fn], args));
};
"use strict";
var cancelable = require("./cancelable");
const cancelable = require("./cancelable");
var makeEventAdder = require("./_makeEventAdder");
const makeEventAdder = require("./_makeEventAdder");
var fromEvent = cancelable(function ($cancelToken, emitter, event, opts) {
if (opts === void 0) {
opts = {};
}
const fromEvent = cancelable(($cancelToken, emitter, event, opts = {}) => new Promise((resolve, reject) => {
const add = makeEventAdder($cancelToken, emitter, opts.array);
add(event, resolve);
return new Promise(function (resolve, reject) {
var add = makeEventAdder($cancelToken, emitter, opts.array);
add(event, resolve);
if (!opts.ignoreErrors) {
var _opts = opts,
_opts$error = _opts.error,
if (!opts.ignoreErrors) {
const _opts$error = opts.error,
error = _opts$error === void 0 ? "error" : _opts$error;
if (error !== event) {
add(error, reject);
}
if (error !== event) {
add(error, reject);
}
});
});
}
}));
module.exports = fromEvent;
"use strict";
var cancelable = require("./cancelable");
const cancelable = require("./cancelable");
var makeEventAdder = require("./_makeEventAdder");
const makeEventAdder = require("./_makeEventAdder");
var _require = require("./_utils"),
forArray = _require.forArray;
const _require = require("./_utils"),
forArray = _require.forArray;
var fromEvents = cancelable(function ($cancelToken, emitter, successEvents, errorEvents) {
if (errorEvents === void 0) {
errorEvents = ["error"];
}
return new Promise(function (resolve, reject) {
var add = makeEventAdder($cancelToken, emitter, true);
forArray(successEvents, function (event) {
return add(event, resolve);
});
forArray(errorEvents, function (event) {
return add(event, reject);
});
});
});
const fromEvents = cancelable(($cancelToken, emitter, successEvents, errorEvents = ["error"]) => new Promise((resolve, reject) => {
const add = makeEventAdder($cancelToken, emitter, true);
forArray(successEvents, event => add(event, resolve));
forArray(errorEvents, event => add(event, reject));
}));
module.exports = fromEvents;
"use strict";
var isProgrammerError = require("./_isProgrammerError");
const isProgrammerError = require("./_isProgrammerError");
var cb = function cb(error) {
const cb = error => {
if (isProgrammerError(error)) {

@@ -7,0 +7,0 @@ throw error;

"use strict";
var isPromise = function isPromise(value) {
return value != null && typeof value.then === "function";
};
const isPromise = value => value != null && typeof value.then === "function";
module.exports = isPromise;
"use strict";
var noop = require("./_noop");
const noop = require("./_noop");
var _require = require("./_utils"),
makeAsyncIterator = _require.makeAsyncIterator;
const _require = require("./_utils"),
makeAsyncIterator = _require.makeAsyncIterator;
var makeAsyncIteratorWrapper = function makeAsyncIteratorWrapper(iterator) {
var asyncIterator = makeAsyncIterator(iterator);
const makeAsyncIteratorWrapper = iterator => {
const asyncIterator = makeAsyncIterator(iterator);
return function asyncIteratorWrapper(iteratee) {

@@ -11,0 +11,0 @@ return asyncIterator(this, iteratee).then(noop);

"use strict";
var setFunctionNameAndLength = require("./_setFunctionNameAndLength");
const setFunctionNameAndLength = require("./_setFunctionNameAndLength");
var wrapApply = require('./wrapApply');
const wrapApply = require("./wrapApply");
var slice = Array.prototype.slice;
const slice = Array.prototype.slice;
var nodeify = function nodeify(fn) {
return setFunctionNameAndLength(function () {
var last = arguments.length - 1;
var cb;
const nodeify = fn => setFunctionNameAndLength(function () {
const last = arguments.length - 1;
let cb;
if (last < 0 || typeof (cb = arguments[last]) !== "function") {
throw new TypeError("missing callback");
}
if (last < 0 || typeof (cb = arguments[last]) !== "function") {
throw new TypeError("missing callback");
}
var args = slice.call(arguments, 0, last);
wrapApply(fn, args).then(function (value) {
return cb(undefined, value);
}, cb);
}, fn.name, fn.length + 1);
};
const args = slice.call(arguments, 0, last);
wrapApply(fn, args).then(value => cb(undefined, value), cb);
}, fn.name, fn.length + 1);
module.exports = nodeify;
{
"name": "promise-toolbox",
"version": "0.19.2",
"version": "0.20.0",
"license": "ISC",

@@ -43,7 +43,2 @@ "description": "Essential utils for promises",

},
"preferGlobal": false,
"files": [
"*.js",
"*.js.map"
],
"browserslist": [

@@ -53,3 +48,3 @@ ">2%"

"engines": {
"node": ">=4"
"node": ">=6"
},

@@ -62,23 +57,20 @@ "dependencies": {

"@babel/core": "^7.0.0",
"@babel/eslint-parser": "^7.13.14",
"@babel/plugin-proposal-function-bind": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^10.0.1",
"babel-jest": "^24.8.0",
"babel-minify": "^0.5.0",
"babelify": "^10.0.0",
"browserify": "^17.0.0",
"cross-env": "^6.0.0",
"eslint": "^6.0.0",
"eslint-config-prettier": "^6.3.0",
"eslint-config-standard": "^14.1.0",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-node": "^10.0.0",
"eslint-plugin-promise": "^4.0.0",
"eslint-plugin-standard": "^4.0.0",
"husky": "^3.0.7",
"jest": "^24.8.0",
"lint-staged": "^9.4.1",
"prettier": "^1.16.4",
"rimraf": "^3.0.0"
"cross-env": "^7.0.3",
"eslint": "^7.25.0",
"eslint-config-prettier": "^8.3.0",
"eslint-config-standard": "^16.0.2",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^4.3.1",
"husky": "^4.3.8",
"jest": "^26.6.3",
"lint-staged": "^10.5.4",
"prettier": "^2.2.1",
"rimraf": "^3.0.0",
"terser": "^5.7.0"
},

@@ -90,3 +82,3 @@ "scripts": {

"dev-test": "jest --bail --watch",
"postbuild": "browserify -s promiseToolbox index.js | babel-minify > umd.js",
"postbuild": "browserify -s promiseToolbox index.js | terser -cm > umd.js",
"prebuild": "npm run clean",

@@ -99,3 +91,2 @@ "predev": "npm run prebuild",

"jest": {
"collectCoverage": true,
"testEnvironment": "node",

@@ -114,4 +105,4 @@ "roots": [

"*.js": [
"echo",
"prettier --write",
"git add",
"eslint --ignore-pattern '!*'",

@@ -118,0 +109,0 @@ "jest --findRelatedTests --passWithNoTests"

"use strict";
var isArray = Array.isArray,
slice = Array.prototype.slice;
const isArray = Array.isArray,
slice = Array.prototype.slice;
var chain = function chain(promise, fn) {
return promise.then(fn);
};
const chain = (promise, fn) => promise.then(fn);

@@ -20,5 +18,3 @@ module.exports = function pPipe(fns) {

return function (arg) {
return fns.reduce(chain, Promise.resolve(arg));
};
return arg => fns.reduce(chain, Promise.resolve(arg));
};
"use strict";
var setFunctionNameAndLength = require("./_setFunctionNameAndLength");
const setFunctionNameAndLength = require("./_setFunctionNameAndLength");
var promisify = function promisify(fn, context) {
return setFunctionNameAndLength(function () {
var _this = this;
const promisify = (fn, context) => setFunctionNameAndLength(function () {
const length = arguments.length;
const args = new Array(length + 1);
var length = arguments.length;
var args = new Array(length + 1);
for (let i = 0; i < length; ++i) {
args[i] = arguments[i];
}
for (var i = 0; i < length; ++i) {
args[i] = arguments[i];
}
return new Promise((resolve, reject) => {
args[length] = (error, result) => error != null && error !== false ? reject(error) : resolve(result);
return new Promise(function (resolve, reject) {
args[length] = function (error, result) {
return error != null && error !== false ? reject(error) : resolve(result);
};
fn.apply(context === undefined ? this : context, args);
});
}, fn.name, fn.length - 1);
fn.apply(context === undefined ? _this : context, args);
});
}, fn.name, fn.length - 1);
};
module.exports = promisify;
"use strict";
var promisify = require("./promisify");
const promisify = require("./promisify");
var _require = require("./_utils"),
forIn = _require.forIn;
const _require = require("./_utils"),
forIn = _require.forIn;
var DEFAULT_MAPPER = function DEFAULT_MAPPER(_, name) {
return !(name.endsWith("Sync") || name.endsWith("Async")) && name;
};
const DEFAULT_MAPPER = (_, name) => !(name.endsWith("Sync") || name.endsWith("Async")) && name;
var promisifyAll = function promisifyAll(obj, _temp) {
var _ref = _temp === void 0 ? {} : _temp,
_ref$mapper = _ref.mapper,
mapper = _ref$mapper === void 0 ? DEFAULT_MAPPER : _ref$mapper,
_ref$target = _ref.target,
target = _ref$target === void 0 ? {} : _ref$target,
_ref$context = _ref.context,
context = _ref$context === void 0 ? obj : _ref$context;
const promisifyAll = (obj, {
mapper = DEFAULT_MAPPER,
target = {},
context = obj
} = {}) => {
forIn(obj, (value, name) => {
let newName;
forIn(obj, function (value, name) {
var newName;
if (typeof value === "function" && (newName = mapper(value, name, obj))) {

@@ -25,0 +19,0 @@ target[newName] = promisify(value, context);

@@ -143,3 +143,3 @@ # promise-toolbox

// Create a token which requests cancelation when a button is clicked.
const token = new CancelToken(cancel => {
const token = new CancelToken((cancel) => {
$("#some-button").on("click", () => cancel("button clicked"));

@@ -185,3 +185,3 @@ });

// 3.
token.promise.then(reason => {
token.promise.then((reason) => {
console.log("cancelation has been requested", reason.message);

@@ -220,3 +220,3 @@ });

hostname: "example.org",
}).then(response => {
}).then((response) => {
// do something with the response of the request

@@ -338,3 +338,3 @@ });

```js
const getTable = Disposable.factory(async function*() {
const getTable = Disposable.factory(async function* () {
// simply yield a disposable to use it

@@ -397,3 +397,3 @@ const db = yield getDb();

```js
await Disposable.use(async function*() {
await Disposable.use(async function* () {
const table1 = yield getTable();

@@ -409,2 +409,22 @@ const table2 = yield getTable();

To enable an entire function to use disposables, you can use `Disposable.wrap`:
```js
// context (`this`) and all arguments are forwarded from the call
const disposableUser = Disposable.wrap(async function* (arg1, arg2) {
const table = yield getDisposable(arg1, arg2);
// do something with table
});
// similar to
function disposableUser(arg1, arg2) {
return Disposable.use(async function* (arg1, arg2) {
const table = yield getDisposable(arg1, arg2);
// do something with table
});
}
```
### Functions

@@ -458,3 +478,3 @@

```js
const cancelableAsyncFunction = asyncFn.cancelable(function*(
const cancelableAsyncFunction = asyncFn.cancelable(function* (
cancelToken,

@@ -507,3 +527,3 @@ ...args

promise.then(value => {
promise.then((value) => {
console.log(value);

@@ -523,3 +543,3 @@ });

// callback is appended to the list of arguments passed to the function
fromCallback(fs.readFile, "foo.txt").then(content => {
fromCallback(fs.readFile, "foo.txt").then((content) => {
console.log(content);

@@ -529,3 +549,3 @@ });

// if the callback does not go at the end, you can wrap the call
fromCallback(cb => foo("bar", cb, "baz")).then(() => {
fromCallback((cb) => foo("bar", cb, "baz")).then(() => {
// ...

@@ -565,6 +585,6 @@ });

promise.then(
value => {
(value) => {
console.log("foo event was emitted with value", value);
},
reason => {
(reason) => {
console.error("an error has been emitted", reason);

@@ -585,3 +605,3 @@ }

fromEvents(emitter, ["foo", "bar"], ["error1", "error2"]).then(
event => {
(event) => {
console.log(

@@ -593,3 +613,3 @@ "event %s have been emitted with values",

},
reasons => {
(reasons) => {
console.error(

@@ -671,5 +691,5 @@ "error event %s has been emitted with errors",

readFile(__filename).then(content => console.log(content));
readFile(__filename).then((content) => console.log(content));
fsPromise.readFile(__filename).then(content => console.log(content));
fsPromise.readFile(__filename).then((content) => console.log(content));
```

@@ -777,3 +797,3 @@

const getUserById = id =>
const getUserById = (id) =>
PromiseToolbox.try(() => {

@@ -802,3 +822,3 @@ if (typeof id !== "number") {

wrapCall(getUserById, "foo").catch(error => {
wrapCall(getUserById, "foo").catch((error) => {
// id must be a number

@@ -818,3 +838,3 @@ });

promises::all().then(values => {
promises::all().then((values) => {
console.log(values);

@@ -832,3 +852,3 @@ });

all.call(promises).then(function(values) {
all.call(promises).then(function (values) {
console.log(values);

@@ -867,9 +887,9 @@ });

})
::pCatch(TypeError, ReferenceError, reason => {
::pCatch(TypeError, ReferenceError, (reason) => {
// Will end up here on programmer error
})
::pCatch(NetworkError, TimeoutError, reason => {
::pCatch(NetworkError, TimeoutError, (reason) => {
// Will end up here on expected everyday network errors
})
::pCatch(reason => {
::pCatch((reason) => {
// Catch any unexpected errors

@@ -915,7 +935,7 @@ });

```js
["foo", Promise.resolve("bar")]::forEach(value => {
["foo", Promise.resolve("bar")]::forEach((value) => {
console.log(value);
// Wait for the promise to be resolve before the next item.
return new Promise(resolve => setTimeout(resolve, 10));
return new Promise((resolve) => setTimeout(resolve, 10));
});

@@ -937,3 +957,3 @@ // →

readFileAsync("foo.txt")
.then(content => {
.then((content) => {
console.log(content);

@@ -945,3 +965,3 @@ })

readFileAsync("foo.txt")
.then(content => {
.then((content) => {
console.lgo(content); // typo

@@ -1018,3 +1038,3 @@ })

$(document).on("ready", () => {
promise.catch(error => {
promise.catch((error) => {
console.error("error while getting user", error);

@@ -1037,3 +1057,3 @@ });

// value.
const promise1 = Promise.resolve(42)::tap(value => {
const promise1 = Promise.resolve(42)::tap((value) => {
console.log(value);

@@ -1043,3 +1063,3 @@ });

// Like .then, the second param is used in case of rejection.
const promise2 = Promise.reject(42)::tap(null, reason => {
const promise2 = Promise.reject(42)::tap(null, (reason) => {
console.error(reason);

@@ -1046,0 +1066,0 @@ });

"use strict";
var FN_FALSE = function FN_FALSE() {
return false;
};
const FN_FALSE = () => false;
var FN_TRUE = function FN_TRUE() {
return true;
};
const FN_TRUE = () => true;
var onFulfilled = function (__proto__) {
return function (_value) {
return {
__proto__: __proto__,
value: function value() {
return _value;
}
};
};
}({
const onFulfilled = (__proto__ => _value => ({
__proto__: __proto__,
value: () => _value
}))({
isFulfilled: FN_TRUE,
isPending: FN_FALSE,
isRejected: FN_FALSE,
reason: function reason() {
reason: () => {
throw new Error("no reason, the promise has resolved");

@@ -29,16 +19,10 @@ }

var onRejected = function (__proto__) {
return function (_reason) {
return {
__proto__: __proto__,
reason: function reason() {
return _reason;
}
};
};
}({
const onRejected = (__proto__ => _reason => ({
__proto__: __proto__,
reason: () => _reason
}))({
isFulfilled: FN_FALSE,
isPending: FN_FALSE,
isRejected: FN_TRUE,
value: function value() {
value: () => {
throw new Error("no value, the promise has rejected");

@@ -45,0 +29,0 @@ }

"use strict";
var matchError = require("./_matchError");
const matchError = require("./_matchError");
var noop = require("./_noop");
const noop = require("./_noop");
var setFunctionNameAndLength = require("./_setFunctionNameAndLength");
const setFunctionNameAndLength = require("./_setFunctionNameAndLength");
function retry(fn, _temp, args) {
var _this = this;
function retry(fn, {
delay,
delays,
onRetry = noop,
retries,
tries,
when
} = {}, args) {
let shouldRetry;
var _ref = _temp === void 0 ? {} : _temp,
delay = _ref.delay,
delays = _ref.delays,
_ref$onRetry = _ref.onRetry,
onRetry = _ref$onRetry === void 0 ? noop : _ref$onRetry,
retries = _ref.retries,
tries = _ref.tries,
when = _ref.when;
var shouldRetry;
if (delays !== undefined) {

@@ -28,8 +24,8 @@ if (delay !== undefined || tries !== undefined || retries !== undefined) {

var iterator = delays[Symbol.iterator]();
const iterator = delays[Symbol.iterator]();
shouldRetry = function shouldRetry() {
var _iterator$next = iterator.next(),
done = _iterator$next.done,
value = _iterator$next.value;
shouldRetry = () => {
const _iterator$next = iterator.next(),
done = _iterator$next.done,
value = _iterator$next.value;

@@ -54,19 +50,13 @@ if (done) {

shouldRetry = function shouldRetry() {
return --tries !== 0;
};
shouldRetry = () => --tries !== 0;
}
when = matchError.bind(undefined, when);
var attemptNumber = 0;
let attemptNumber = 0;
var sleepResolver = function sleepResolver(resolve) {
return setTimeout(resolve, delay);
};
const sleepResolver = resolve => setTimeout(resolve, delay);
var sleep = function sleep() {
return new Promise(sleepResolver);
};
const sleep = () => new Promise(sleepResolver);
var onError = function onError(error) {
const onError = error => {
if (error instanceof ErrorContainer) {

@@ -77,3 +67,3 @@ throw error.error;

if (when(error) && shouldRetry()) {
var promise = Promise.resolve(onRetry.call({
let promise = Promise.resolve(onRetry.call({
arguments: args,

@@ -83,3 +73,3 @@ attemptNumber: attemptNumber++,

fn,
this: _this
this: this
}, error));

@@ -97,9 +87,5 @@

var loopResolver = function loopResolver(resolve) {
return resolve(fn.apply(_this, args));
};
const loopResolver = resolve => resolve(fn.apply(this, args));
var loop = function loop() {
return new Promise(loopResolver).catch(onError);
};
const loop = () => new Promise(loopResolver).catch(onError);

@@ -120,5 +106,3 @@ return loop();

retry.wrap = function retryWrap(fn, options) {
var getOptions = typeof options !== "function" ? function () {
return options;
} : options;
const getOptions = typeof options !== "function" ? () => options : options;
return setFunctionNameAndLength(function () {

@@ -125,0 +109,0 @@ return retry.call(this, fn, getOptions.apply(this, arguments), Array.from(arguments));

"use strict";
var resolve = require("./_resolve");
const resolve = require("./_resolve");
var _require = require("./_utils"),
forEach = _require.forEach;
const _require = require("./_utils"),
forEach = _require.forEach;
var _some = function _some(promises, count) {
return new Promise(function (resolve, reject) {
var values = [];
var errors = [];
const _some = (promises, count) => new Promise((resolve, reject) => {
let values = [];
let errors = [];
var onFulfillment = function onFulfillment(value) {
if (!values) {
return;
}
const onFulfillment = value => {
if (!values) {
return;
}
values.push(value);
values.push(value);
if (--count === 0) {
resolve(values);
values = errors = undefined;
}
};
if (--count === 0) {
resolve(values);
values = errors = undefined;
}
};
var acceptableErrors = -count;
let acceptableErrors = -count;
var onRejection = function onRejection(reason) {
if (!values) {
return;
}
const onRejection = reason => {
if (!values) {
return;
}
errors.push(reason);
errors.push(reason);
if (--acceptableErrors === 0) {
reject(errors);
values = errors = undefined;
}
};
if (--acceptableErrors === 0) {
reject(errors);
values = errors = undefined;
}
};
forEach(promises, function (promise) {
++acceptableErrors;
resolve(promise).then(onFulfillment, onRejection);
});
forEach(promises, promise => {
++acceptableErrors;
resolve(promise).then(onFulfillment, onRejection);
});
};
});
module.exports = function some(count) {
return resolve(this).then(function (promises) {
return _some(promises, count);
});
return resolve(this).then(promises => _some(promises, count));
};
"use strict";
var noop = require("./_noop");
const noop = require("./_noop");
module.exports = function suppressUnhandledRejections() {
var native = this.suppressUnhandledRejections;
const native = this.suppressUnhandledRejections;

@@ -8,0 +8,0 @@ if (typeof native === "function") {

"use strict";
module.exports = function tap(onFulfilled, onRejected) {
var _this = this;
return this.then(onFulfilled, onRejected).then(function () {
return _this;
});
return this.then(onFulfilled, onRejected).then(() => this);
};
"use strict";
module.exports = function tapCatch(cb) {
var _this = this;
return this.then(undefined, cb).then(function () {
return _this;
});
return this.then(undefined, cb).then(() => this);
};
"use strict";
var TimeoutError = require("./TimeoutError");
const TimeoutError = require("./TimeoutError");
module.exports = function timeout(ms, onReject) {
var _this = this;
if (ms === 0) {

@@ -16,8 +14,8 @@ return this;

return new Promise(function (resolve, reject) {
var handle = setTimeout(function () {
return new Promise((resolve, reject) => {
let handle = setTimeout(() => {
handle = undefined;
if (typeof _this.cancel === "function") {
_this.cancel();
if (typeof this.cancel === "function") {
this.cancel();
}

@@ -35,7 +33,6 @@

}, ms);
_this.then(function (value) {
this.then(value => {
handle !== undefined && clearTimeout(handle);
resolve(value);
}, function (reason) {
}, reason => {
handle !== undefined && clearTimeout(handle);

@@ -42,0 +39,0 @@ reject(reason);

"use strict";
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
const _require = require("make-error"),
BaseError = _require.BaseError;
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
var _require = require("make-error"),
BaseError = _require.BaseError;
module.exports = function (_BaseError) {
_inheritsLoose(TimeoutError, _BaseError);
function TimeoutError() {
return _BaseError.call(this, "operation timed out") || this;
module.exports = class TimeoutError extends BaseError {
constructor() {
super("operation timed out");
}
return TimeoutError;
}(BaseError);
};
"use strict";
var resolve = require("./_resolve");
const resolve = require("./_resolve");

@@ -5,0 +5,0 @@ module.exports = function pTry(fn) {

@@ -1,1 +0,1 @@

(function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"==typeof window?"undefined"==typeof global?"undefined"==typeof self?this:self:global:window,b.promiseToolbox=a()}})(function(){return function(){function b(d,e,g){function a(j,i){if(!e[j]){if(!d[j]){var f="function"==typeof require&&require;if(!i&&f)return f(j,!0);if(h)return h(j,!0);var c=new Error("Cannot find module '"+j+"'");throw c.code="MODULE_NOT_FOUND",c}var k=e[j]={exports:{}};d[j][0].call(k.exports,function(b){var c=d[j][1][b];return a(c||b)},k,k.exports,b,d,e,g)}return e[j].exports}for(var h="function"==typeof require&&require,c=0;c<g.length;c++)a(g[c]);return a}return b}()({1:[function(a,b){"use strict";b.exports=function(){function a(a){void 0===a&&(a="this action has been canceled"),Object.defineProperty(this,"message",{enumerable:!0,value:a})}var b=a.prototype;return b.toString=function(){return`Cancel: ${this.message}`},a}()},{}],2:[function(a,b){"use strict";function c(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}function d(a,b,d){return b&&c(a.prototype,b),d&&c(a,d),a}function e(a){if(void 0===this._reason){var b=this._reason=a instanceof j?a:new j(a),c=this._resolve;void 0!==c&&(this._resolve=void 0,c(b));var d=this.onabort;"function"==typeof d&&d();var e=this._handlers;if(void 0!==e){this._handlers=void 0;for(var f=h(),g=f.promise,l=f.resolve,m=0,o=function(){if(0==--m)return l()},p=0,q=e.length;p<q;++p)try{var n=e[p](b);k(n)&&(++m,n.then(o,o))}catch(a){}if(0!==m)return g}}}function f(a){var b=this._handlers;if(b!==void 0){var c=b.indexOf(a);-1!==c&&b.splice(c,1)}}function g(a){var b=this.cancel=e.bind(this.token=new q(p));null==a||a.forEach(function(a){var c=a.reason;return void 0===c?void a.addHandler(b):(b(c),!1)})}var h=a("./defer"),j=a("./Cancel"),k=a("./isPromise"),l=a("./_noop"),m=a("./_symbols"),n=m.$$toStringTag,o="CancelToken",p={},q=function(){function a(a){this._handlers=void 0,this._promise=void 0,this._reason=void 0,this._resolve=void 0,this.onabort=void 0,a!==p&&a(e.bind(this))}a.from=function(b){if(a.isCancelToken(b))return b;var c=new a(p);return b.addEventListener("abort",e.bind(c)),c},a.isCancelToken=function(a){return null!=a&&a[n]===o},a.source=function(a){return new g(a)};var b=a.prototype;return b.addHandler=function(a){var b=this._handlers;if(void 0===b){if(this.requested)throw new TypeError("cannot add a handler to an already canceled token");b=this._handlers=[]}return b.push(a),f.bind(this,a)},b.throwIfRequested=function(){var a=this._reason;if(void 0!==a)throw a},b.addEventListener=function(a,b){if("abort"===a){var c={type:"abort"},d="function"==typeof b?function(){return b(c)}:function(){return b.handleEvent(c)};d.listener=b,this.addHandler(d)}},b.removeEventListener=function(a,b){if("abort"===a){var c=this._handlers;if(void 0!==c){var d=c.findIndex(function(a){return a.listener===b});-1!==d&&c.splice(d,1)}}},d(a,[{key:"promise",get:function(){var a=this,b=this._promise;if(void 0===b){var c=this._reason;b=this._promise=void 0===c?new Promise(function(b){a._resolve=b}):Promise.resolve(c)}return b}},{key:"reason",get:function(){return this._reason}},{key:"requested",get:function(){return void 0!==this._reason}},{key:n,get:function(){return o}},{key:"aborted",get:function(){return this.requested}}]),a}();e.call(q.canceled=new q(p)),q.none=new q(p),q.none.addHandler=function(){return l},q.none._promise={catch(){return this},then(){return this}},b.exports=q},{"./Cancel":1,"./_noop":13,"./_symbols":17,"./defer":23,"./isPromise":36}],3:[function(a,b){"use strict";function c(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}function d(a,b,d){return b&&c(a.prototype,b),d&&c(a,d),a}var e=a("./_evalDisposable"),f=a("./_isDisposable"),g=a("./_finally"),h=a("./_setFunctionNameAndLength"),i=a("./wrapApply"),j=a("./wrapCall"),k=function(){function a(a,b){if("function"!=typeof a)throw new Error("dispose must be a function");this._dispose=a,this._value=b}var b=a.prototype;return b.dispose=function(){if(void 0===this._dispose)throw new TypeError("this disposable has already been disposed");var a=this._dispose;return this._dispose=this._value=void 0,a()},d(a,[{key:"value",get:function(){if(void 0===this._dispose)throw new TypeError("this disposable has already been disposed");return this._value}}]),a}();b.exports=k,k.all=function(a){var b=[],c=function(){var a=b;b=void 0,a.forEach(function(a){return a.dispose()})},d=function(a){return void 0===b?f(a)&&a.dispose():f(a)?(b.push(a),a.value):a},g=function(a){if(void 0!==b)throw c(),a};return Promise.all(Array.from(a,function(a){return e(a).then(d,g)})).then(function(a){return new k(c,a)})};var l=a("./_ExitStack");k.factory=function(a){return h(function(){var b=a.apply(this,arguments),c=new l,d=c.dispose,g=c.value,h=function(a){return f(a)?m(g.enter(a)):a},i=function(a){var b=a.value;return e(b).then(h)},m=function(a){return j(b.next,a,b).then(i)};return m().then(function(a){return new k(function(){return j(b.return,void 0,b).then(d)},a)},function(a){var b=function(){throw a};return d().then(b,b)})},a.name,a.length)};var m=function(a){var b=new l,c=b.dispose,d=b.value,f=function(a){return i(d.enter(a))},h=function(a){return a.done?a.value:e(a.value).then(f)},i=function(b){return j(a.next,b,a).then(h)};return g(i(),c)};k.use=function(){var a=this,b=arguments.length-1;if(0>b)throw new TypeError("Disposable.use expects at least 1 argument");var c=arguments[b];if(0===b)return new Promise(function(b){return b(c.call(a))}).then(m);var d,e=!Array.isArray(d=arguments[0]);return e?d=Array.prototype.slice.call(arguments,0,b):b=d.length,k.all(d).then(function(b){return g((e?i:j)(c,b.value,a),function(){return b.dispose()})})}},{"./_ExitStack":5,"./_evalDisposable":6,"./_finally":7,"./_isDisposable":9,"./_setFunctionNameAndLength":16,"./wrapApply":52,"./wrapCall":53}],4:[function(a,b){"use strict";function c(a,b){a.prototype=Object.create(b.prototype),a.prototype.constructor=a,d(a,b)}function d(a,b){return d=Object.setPrototypeOf||function(a,b){return a.__proto__=b,a},d(a,b)}var e=a("make-error"),f=e.BaseError;b.exports=function(a){function b(){return a.call(this,"operation timed out")||this}return c(b,a),b}(f)},{"make-error":38}],5:[function(a,b){"use strict";var c=a("./_isDisposable"),d=a("./_resolve");b.exports=function(){function a(){var a=this;this._disposables=[];return{dispose:function b(){var c=a._disposables.pop();return void 0===c?Promise.resolve():d(c.dispose()).then(b)},value:this}}var b=a.prototype;return b.enter=function(a){if(!c(a))throw new TypeError("not a disposable");return this._disposables.push(a),a.value},a}()},{"./_isDisposable":9,"./_resolve":15}],6:[function(a,b){"use strict";var c=a("./try");b.exports=function(a){return"function"==typeof a?c(a):Promise.resolve(a)}},{"./try":50}],7:[function(a,b){"use strict";b.exports=function(a,b){return a.then(b,b).then(function(){return a})}},{}],8:[function(a,b){"use strict";b.exports=function(a){return a}},{}],9:[function(a,b){"use strict";b.exports=function(a){return null!=a&&"function"==typeof a.dispose}},{}],10:[function(a,b){"use strict";b.exports=function(a){return a instanceof ReferenceError||a instanceof SyntaxError||a instanceof TypeError}},{}],11:[function(a,b){"use strict";var c=a("./_noop"),d=a("./_once");b.exports=function(a,b,e){var f=b.addEventListener||b.addListener||b.on;if(void 0===f)throw new Error("cannot register event listener");var g=b.removeEventListener||b.removeListener||b.off,h=[],i=c;return void 0!==g&&(i=d(function(){for(var a=0,c=h.length;a<c;a+=2)g.call(b,h[a],h[a+1])}),a.promise.then(i)),e?function(a,c){function d(){i();var b=Array.prototype.slice.call(arguments);b.args=b,b.event=b.name=a,c(b)}h.push(a,d),f.call(b,a,d)}:function(a,c){var d=function(a){i(),c(a)};h.push(a,d),f.call(b,a,d)}}},{"./_noop":13,"./_once":14}],12:[function(a,b){"use strict";var c=a("./_isProgrammerError");b.exports=function a(b,d){if(b===void 0)return!c(d);var e=typeof b;if("boolean"==e)return b;if("function"==e)return b===Error||b.prototype instanceof Error?d instanceof b:b(d);if(Array.isArray(b)){for(var f=b.length,g=0;g<f;++g)if(a(b[g],d))return!0;return!1}if(null!=d&&"object"===e){for(var h in b)if(hasOwnProperty.call(b,h)&&d[h]!==b[h])return!1;return!0}}},{"./_isProgrammerError":10}],13:[function(a,b){"use strict";b.exports=Function.prototype},{}],14:[function(a,b){"use strict";b.exports=function(a){var b;return function(){return void 0!==a&&(b=a.apply(this,arguments),a=void 0),b}}},{}],15:[function(a,b){"use strict";var c=a("./isPromise");b.exports=function(a){return c(a)?a:Promise.resolve(a)}},{"./isPromise":36}],16:[function(a,b){"use strict";b.exports=function(){var b=Object.defineProperties;try{var c=b(function(){},{length:{value:2},name:{value:"foo"}});if(2===c.length&&"foo"===c.name)return function(a,c,d){return b(a,{length:{configurable:!0,value:0<d?d:0},name:{configurable:!0,value:c}})}}catch(a){}return a("./_identity")}()},{"./_identity":8}],17:[function(a,b,c){"use strict";var d="function"==typeof Symbol?function(a){var b=Symbol[a];return b===void 0?`@@${a}`:b}:function(a){return`@@${a}`};c.$$iterator=d("iterator"),c.$$toStringTag=d("toStringTag")},{}],18:[function(a,b,c){"use strict";if("function"!=typeof Promise||"function"!=typeof Promise.reject||"function"!=typeof Promise.resolve)throw new Error("a standard Promise implementation is required (https://github.com/JsCommunity/promise-toolbox#usage)");var d=a("./isPromise"),e=a("./_symbols"),f=e.$$iterator,g=c.forArray=function(a,b){for(var c=a.length,d=0;d<c;++d)b(a[d],d,a)};c.forIn=function(a,b){for(var c in a)b(a[c],c,a)};var h=c.forIterable=function(a,b){for(var c,d=a[f]();!(c=d.next()).done;)b(c.value,void 0,a)},i=Object.prototype.hasOwnProperty,j=c.forOwn=function(a,b){for(var c in a)i.call(a,c)&&b(a[c],c,a)},k=function(a){return null!=a&&"function"==typeof a[f]},l=c.forEach=function(a,b){return Array.isArray(a)?g(a,b):k(a)?h(a,b):n(a)?g(a,b):j(a,b)},m=function(a){return"number"==typeof a&&0<=a&&a<1/0&&Math.floor(a)===a},n=c.isArrayLike=function(a){return"function"!=typeof a&&null!=a&&m(a.length)};c.makeAsyncIterator=function(a){return function b(c,e){if(d(c))return c.then(function(a){return b(a,e)});var f=Promise.resolve();return a(c,function(a,b){f=d(a)?f.then(function(){return a.then(function(a){return e(a,b,c)})}):f.then(function(){return e(a,b,c)})}),f}},c.map=function(a,b){var c=[];return l(a,function(a,d,e){c.push(b(a,d,e))}),c},c.mapAuto=function(a,b){var c=n(a)?Array(a.length):Object.create(null);return void 0!==b&&l(a,function(a,d,e){c[d]=b(a,d,e)}),c}},{"./_symbols":17,"./isPromise":36}],19:[function(a,b){"use strict";b.exports=function(a){return"function"==typeof a&&this.then(function(b){return a(void 0,b)},a),this}},{}],20:[function(a,b){"use strict";function c(a,b){var c;try{c=this._iterator[a](b)}catch(a){return this.finally(),this._reject(a)}b=c.value,c.done?(this.finally(),this._resolve(b)):this.toPromise(b).then(this.next,this._throw)}function d(a,b,d){this._iterator=a,this._reject=d,this._resolve=b,this._throw=c.bind(this,"throw"),this.next=c.bind(this,"next")}function e(a){var b=this;d.apply(this,[].slice.call(arguments,1)),this._cancelToken=a,this._onCancel=i,this.finally=a.addHandler(function(a){return b._onCancel(a),new Promise(function(a){b.finally=a})})}var f=a("./_identity"),g=a("./isPromise"),h=a("./_resolve"),i=Function.prototype;d.prototype.finally=i,d.prototype.toPromise=h;var j=function(a){return function(){var b=arguments,c=this;return new Promise(function(e,f){return new d(a.apply(c,b),e,f).next()})}};Object.setPrototypeOf(e.prototype,Object.getPrototypeOf(d.prototype)).toPromise=function(a){var b=this;if(Array.isArray(a))return h(a[0]);var c=this._cancelToken;return c.requested?Promise.reject(c.reason):g(a)?new Promise(function(c,d){a.then(c,d),b._onCancel=d}):Promise.resolve(a)},j.cancelable=function(a,b){return void 0===b&&(b=f),function(){var c=arguments,d=this,f=b.apply(this,arguments);return f.requested?Promise.reject(f.reason):new Promise(function(b,g){new e(f,a.apply(d,c),b,g).next()})}},b.exports=j},{"./_identity":8,"./_resolve":15,"./isPromise":36}],21:[function(a,b){"use strict";var c=a("./_setFunctionNameAndLength"),d=a("./CancelToken"),e=d.isCancelToken,f=d.source;b.exports=function(a,b,d){var g=d===void 0?a:d.value,h=c(function(){var a=arguments.length;if(0!==a&&e(arguments[0]))return g.apply(this,arguments);var b=f(),c=b.cancel,d=b.token,h=Array(a+1);h[0]=d;for(var j=0;j<a;++j)h[j+1]=arguments[j];var k=g.apply(this,h);return k.cancel=c,k},g.name,g.length-1);return void 0===d?h:(d.value=h,d)}},{"./CancelToken":2,"./_setFunctionNameAndLength":16}],22:[function(a,b){"use strict";function c(a,b,c){return d(a,c)?b(c):this}var d=a("./_matchError");b.exports=function(){var a,b=arguments.length;return 0===b||"function"!=typeof(a=arguments[--b])?this:this.then(void 0,c.bind(this,0===b?void 0:1===b?arguments[0]:Array.prototype.slice.call(arguments,0,b),a))}},{"./_matchError":12}],23:[function(a,b){"use strict";b.exports=function(){var a,b,c=new Promise(function(c,d){a=c,b=d});return{promise:c,reject:b,resolve:a}}},{}],24:[function(a,b){"use strict";var c=a("./isPromise");b.exports=function(a){var b=2===arguments.length?arguments[1]:this;if(c(b))return b.then(function(b){return new Promise(function(c){setTimeout(c,a,b)})});var d,e=new Promise(function(c){d=setTimeout(c,a,b)});return e.unref=function(){return null!=d&&"function"==typeof d.unref&&d.unref(),e},e}},{"./isPromise":36}],25:[function(a,b){"use strict";b.exports=function(a){var b=this;return this.then(a,a).then(function(){return b})}},{}],26:[function(a,b){"use strict";b.exports=a("./makeAsyncIterator")(a("./_utils").forArray)},{"./_utils":18,"./makeAsyncIterator":37}],27:[function(a,b){"use strict";b.exports=a("./makeAsyncIterator")(a("./_utils").forEach)},{"./_utils":18,"./makeAsyncIterator":37}],28:[function(a,b){"use strict";b.exports=a("./makeAsyncIterator")(a("./_utils").forIn)},{"./_utils":18,"./makeAsyncIterator":37}],29:[function(a,b){"use strict";b.exports=a("./makeAsyncIterator")(a("./_utils").forIterable)},{"./_utils":18,"./makeAsyncIterator":37}],30:[function(a,b){"use strict";b.exports=a("./makeAsyncIterator")(a("./_utils").forOwn)},{"./_utils":18,"./makeAsyncIterator":37}],31:[function(a,b){"use strict";function c(a,b,c,d){b.push(function(a,b){return null!=a&&!1!==a?d(a):c(b)}),a.apply(this,b)}b.exports=function(a){for(var b=arguments.length,d=Array(1<b?b-1:0),e=1;e<b;e++)d[e-1]=arguments[e];return new Promise(c.bind(this,"function"==typeof a?a:this[a],d))}},{}],32:[function(a,b){"use strict";var c=a("./cancelable"),d=a("./_makeEventAdder"),e=c(function(a,b,c,e){return void 0===e&&(e={}),new Promise(function(f,g){var h=d(a,b,e.array);if(h(c,f),!e.ignoreErrors){var i=e,j=i.error,k=void 0===j?"error":j;k!==c&&h(k,g)}})});b.exports=e},{"./_makeEventAdder":11,"./cancelable":21}],33:[function(a,b){"use strict";var c=a("./cancelable"),d=a("./_makeEventAdder"),e=a("./_utils"),f=e.forArray,g=c(function(a,b,c,e){return void 0===e&&(e=["error"]),new Promise(function(g,h){var i=d(a,b,!0);f(c,function(a){return i(a,g)}),f(e,function(a){return i(a,h)})})});b.exports=g},{"./_makeEventAdder":11,"./_utils":18,"./cancelable":21}],34:[function(a,b){"use strict";var c=a("./_isProgrammerError"),d=function(a){if(c(a))throw a};b.exports=function(){return this.then(void 0,d)}},{"./_isProgrammerError":10}],35:[function(a,b,c){"use strict";c.pAsCallback=c.asCallback=a("./asCallback"),c.pAsyncFn=c.asyncFn=a("./asyncFn"),c.pCancel=c.Cancel=a("./Cancel"),c.pCancelable=c.cancelable=a("./cancelable"),c.pCancelToken=c.CancelToken=a("./CancelToken"),c.pCatch=c.catch=a("./catch"),c.pDefer=c.defer=a("./defer"),c.pDelay=c.delay=a("./delay"),c.pDisposable=c.Disposable=a("./Disposable"),c.pFinally=c.finally=a("./finally"),c.pForArray=c.forArray=a("./forArray"),c.pForEach=c.forEach=a("./forEach"),c.pForIn=c.forIn=a("./forIn"),c.pForIterable=c.forIterable=a("./forIterable"),c.pForOwn=c.forOwn=a("./forOwn"),c.pFromCallback=c.fromCallback=a("./fromCallback"),c.pFromEvent=c.fromEvent=a("./fromEvent"),c.pFromEvents=c.fromEvents=a("./fromEvents"),c.pIgnoreErrors=c.ignoreErrors=a("./ignoreErrors"),c.pIsPromise=c.isPromise=a("./isPromise"),c.pMakeAsyncIterator=c.makeAsyncIterator=a("./makeAsyncIterator"),c.pNodeify=c.nodeify=a("./nodeify"),c.pPipe=c.pipe=a("./pipe"),c.pPromisify=c.promisify=a("./promisify"),c.pPromisifyAll=c.promisifyAll=a("./promisifyAll"),c.pReflect=c.reflect=a("./reflect"),c.pRetry=c.retry=a("./retry"),c.pSome=c.some=a("./some"),c.pSuppressUnhandledRejections=c.suppressUnhandledRejections=a("./suppressUnhandledRejections"),c.pTap=c.tap=a("./tap"),c.pTapCatch=c.tapCatch=a("./tapCatch"),c.pTimeout=c.timeout=a("./timeout"),c.pTimeoutError=c.TimeoutError=a("./TimeoutError"),c.pTry=c.try=a("./try"),c.pUnpromisify=c.unpromisify=a("./unpromisify"),c.pWrapApply=c.wrapApply=a("./wrapApply"),c.pWrapCall=c.wrapCall=a("./wrapCall")},{"./Cancel":1,"./CancelToken":2,"./Disposable":3,"./TimeoutError":4,"./asCallback":19,"./asyncFn":20,"./cancelable":21,"./catch":22,"./defer":23,"./delay":24,"./finally":25,"./forArray":26,"./forEach":27,"./forIn":28,"./forIterable":29,"./forOwn":30,"./fromCallback":31,"./fromEvent":32,"./fromEvents":33,"./ignoreErrors":34,"./isPromise":36,"./makeAsyncIterator":37,"./nodeify":39,"./pipe":40,"./promisify":41,"./promisifyAll":42,"./reflect":43,"./retry":44,"./some":45,"./suppressUnhandledRejections":46,"./tap":47,"./tapCatch":48,"./timeout":49,"./try":50,"./unpromisify":51,"./wrapApply":52,"./wrapCall":53}],36:[function(a,b){"use strict";b.exports=function(a){return null!=a&&"function"==typeof a.then}},{}],37:[function(a,b){"use strict";var c=a("./_noop"),d=a("./_utils"),e=d.makeAsyncIterator;b.exports=function(a){var b=e(a);return function(a){return b(this,a).then(c)}}},{"./_noop":13,"./_utils":18}],38:[function(a,b,c){"use strict";function d(a){a!==void 0&&f(this,"message",{configurable:!0,value:a,writable:!0});var b=this.constructor.name;b!==void 0&&b!==this.name&&f(this,"name",{configurable:!0,value:b,writable:!0}),g(this,this.constructor)}var e="undefined"==typeof Reflect?void 0:Reflect.construct,f=Object.defineProperty,g=Error.captureStackTrace;g===void 0&&(g=function(a){var b=new Error;f(a,"stack",{configurable:!0,get:function(){var a=b.stack;return f(this,"stack",{configurable:!0,value:a,writable:!0}),a},set:function(b){f(a,"stack",{configurable:!0,value:b,writable:!0})}})}),d.prototype=Object.create(Error.prototype,{constructor:{configurable:!0,value:d,writable:!0}});var h=function(){function a(a,b){return f(a,"name",{configurable:!0,value:b})}try{var b=function(){};if(a(b,"foo"),"foo"===b.name)return a}catch(a){}}();c=b.exports=function(a,b){if(null==b||b===Error)b=d;else if("function"!=typeof b)throw new TypeError("super_ should be a function");var c;if("string"==typeof a)c=a,a=void 0===e?function(){b.apply(this,arguments)}:function(){return e(b,arguments,this.constructor)},void 0!==h&&(h(a,c),c=void 0);else if("function"!=typeof a)throw new TypeError("constructor should be either a string or a function");a.super_=a["super"]=b;var f={constructor:{configurable:!0,value:a,writable:!0}};return void 0!==c&&(f.name={configurable:!0,value:c,writable:!0}),a.prototype=Object.create(b.prototype,f),a},c.BaseError=d},{}],39:[function(a,b){"use strict";var c=a("./_setFunctionNameAndLength"),d=a("./wrapApply"),e=Array.prototype.slice;b.exports=function(a){return c(function(){var b,c=arguments.length-1;if(0>c||"function"!=typeof(b=arguments[c]))throw new TypeError("missing callback");var f=e.call(arguments,0,c);d(a,f).then(function(a){return b(void 0,a)},b)},a.name,a.length+1)}},{"./_setFunctionNameAndLength":16,"./wrapApply":52}],40:[function(a,b){"use strict";var c=Array.isArray,d=Array.prototype.slice,e=function(a,b){return a.then(b)};b.exports=function(a){return c(a)||(a=d.call(arguments)),"function"==typeof a[0]?function(b){return a.reduce(e,Promise.resolve(b))}:(a[0]=Promise.resolve(a[0]),a.reduce(e))}},{}],41:[function(a,b){"use strict";var c=a("./_setFunctionNameAndLength");b.exports=function(a,b){return c(function(){for(var c=this,d=arguments.length,e=Array(d+1),f=0;f<d;++f)e[f]=arguments[f];return new Promise(function(f,g){e[d]=function(a,b){return null!=a&&!1!==a?g(a):f(b)},a.apply(b===void 0?c:b,e)})},a.name,a.length-1)}},{"./_setFunctionNameAndLength":16}],42:[function(a,b){"use strict";var c=a("./promisify"),d=a("./_utils"),e=d.forIn,f=function(a,b){return!(b.endsWith("Sync")||b.endsWith("Async"))&&b};b.exports=function(a,b){var d=void 0===b?{}:b,g=d.mapper,h=void 0===g?f:g,i=d.target,j=void 0===i?{}:i,k=d.context,l=void 0===k?a:k;return e(a,function(b,d){var e;"function"==typeof b&&(e=h(b,d,a))&&(j[e]=c(b,l))}),j}},{"./_utils":18,"./promisify":41}],43:[function(a,b){"use strict";var c=function(){return!1},d=function(){return!0},e=function(a){return function(b){return{__proto__:a,value:function(){return b}}}}({isFulfilled:d,isPending:c,isRejected:c,reason:function(){throw new Error("no reason, the promise has resolved")}}),f=function(a){return function(b){return{__proto__:a,reason:function(){return b}}}}({isFulfilled:c,isPending:c,isRejected:d,value:function(){throw new Error("no value, the promise has rejected")}});b.exports=function(){return this.then(e,f)}},{}],44:[function(a,b){"use strict";function c(a,b,c){var g,h=this,i=void 0===b?{}:b,j=i.delay,k=i.delays,l=i.onRetry,m=void 0===l?f:l,n=i.retries,o=i.tries,p=i.when;if(k!==void 0){if(j!==void 0||o!==void 0||n!==void 0)throw new TypeError("delays is incompatible with delay, tries and retries");var q=k[Symbol.iterator]();g=function(){var a=q.next(),b=a.done,c=a.value;return!b&&(j=c,!0)}}else{if(o===void 0)o=void 0===n?10:n+1;else if(n!==void 0)throw new TypeError("retries and tries options are mutually exclusive");j===void 0&&(j=1e3),g=function(){return 0!=--o}}p=e.bind(void 0,p);var r=0,s=function(a){return setTimeout(a,j)},t=function(){return new Promise(s)},u=function(b){if(b instanceof d)throw b.error;if(p(b)&&g()){var e=Promise.resolve(m.call({arguments:c,attemptNumber:r++,delay:j,fn:a,this:h},b));return 0!==j&&(e=e.then(t)),e.then(w)}throw b},v=function(b){return b(a.apply(h,c))},w=function(){return new Promise(v).catch(u)};return w()}function d(a){this.error=a}var e=a("./_matchError"),f=a("./_noop"),g=a("./_setFunctionNameAndLength");b.exports=c,c.bail=function(a){throw new d(a)},c.wrap=function(a,b){var d="function"==typeof b?b:function(){return b};return g(function(){return c.call(this,a,d.apply(this,arguments),Array.from(arguments))},a.name,a.length)}},{"./_matchError":12,"./_noop":13,"./_setFunctionNameAndLength":16}],45:[function(a,b){"use strict";var c=a("./_resolve"),d=a("./_utils"),e=d.forEach,f=function(a,b){return new Promise(function(c,d){var f=[],g=[],h=function(a){f&&(f.push(a),0==--b&&(c(f),f=g=void 0))},i=-b,j=function(a){f&&(g.push(a),0==--i&&(d(g),f=g=void 0))};e(a,function(a){++i,c(a).then(h,j)})})};b.exports=function(a){return c(this).then(function(b){return f(b,a)})}},{"./_resolve":15,"./_utils":18}],46:[function(a,b){"use strict";var c=a("./_noop");b.exports=function(){var a=this.suppressUnhandledRejections;return"function"==typeof a?a.call(this):this.then(void 0,c),this}},{"./_noop":13}],47:[function(a,b){"use strict";b.exports=function(a,b){var c=this;return this.then(a,b).then(function(){return c})}},{}],48:[function(a,b){"use strict";b.exports=function(a){var b=this;return this.then(void 0,a).then(function(){return b})}},{}],49:[function(a,b){"use strict";var c=a("./TimeoutError");b.exports=function(a,b){var d=this;return 0===a?this:(void 0===b&&(b=new c),new Promise(function(c,e){var f=setTimeout(function(){if(f=void 0,"function"==typeof d.cancel&&d.cancel(),"function"==typeof b)try{c(b())}catch(a){e(a)}else e(b)},a);d.then(function(a){void 0!==f&&clearTimeout(f),c(a)},function(a){void 0!==f&&clearTimeout(f),e(a)})}))}},{"./TimeoutError":4}],50:[function(a,b){"use strict";var c=a("./_resolve");b.exports=function(a){try{return c(a())}catch(a){return Promise.reject(a)}}},{"./_resolve":15}],51:[function(a,b){"use strict";var c=a("./_setFunctionNameAndLength");b.exports=function(){var a=this;return c(function(){var b,c=arguments.length-1;if(0>c||"function"!=typeof(b=arguments[c]))throw new Error("missing callback");for(var d=Array(c),e=0;e<c;++e)d[e]=arguments[e];a.apply(this,d).then(function(a){return b(void 0,a)},function(a){return b(a)})},a.name,a.length+1)}},{"./_setFunctionNameAndLength":16}],52:[function(a,b){"use strict";var c=a("./_resolve");b.exports=function(a,b,d){try{return c(a.apply(d,b))}catch(a){return Promise.reject(a)}}},{"./_resolve":15}],53:[function(a,b){"use strict";var c=a("./_resolve");b.exports=function(a,b,d){try{return c(a.call(d,b))}catch(a){return Promise.reject(a)}}},{"./_resolve":15}]},{},[35])(35)});
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).promiseToolbox=e()}}((function(){return function e(t,r,n){function o(i,c){if(!r[i]){if(!t[i]){var a="function"==typeof require&&require;if(!c&&a)return a(i,!0);if(s)return s(i,!0);var u=new Error("Cannot find module '"+i+"'");throw u.code="MODULE_NOT_FOUND",u}var l=r[i]={exports:{}};t[i][0].call(l.exports,(function(e){return o(t[i][1][e]||e)}),l,l.exports,e,t,r,n)}return r[i].exports}for(var s="function"==typeof require&&require,i=0;i<n.length;i++)o(n[i]);return o}({1:[function(e,t,r){"use strict";t.exports=class{constructor(e="this action has been canceled"){Object.defineProperty(this,"message",{enumerable:!0,value:e})}toString(){return`Cancel: ${this.message}`}}},{}],2:[function(e,t,r){"use strict";const n=e("./defer"),o=e("./Cancel"),s=e("./isPromise"),i=e("./_noop"),c=e("./_symbols").$$toStringTag,a="CancelToken";function u(e){if(void 0!==this._reason)return;const t=this._reason=e instanceof o?e:new o(e),r=this._resolve;void 0!==r&&(this._resolve=void 0,r(t));const i=this.onabort;"function"==typeof i&&i();const c=this._handlers;if(void 0!==c){this._handlers=void 0;const e=n(),r=e.promise,o=e.resolve;let i=0;const a=()=>{if(0==--i)return o()};for(let e=0,r=c.length;e<r;++e)try{const r=c[e](t);s(r)&&(++i,r.then(a,a))}catch(e){}if(0!==i)return r}}function l(e){const t=this._handlers;if(void 0!==t){const r=t.indexOf(e);-1!==r&&t.splice(r,1)}}const f={};function p(e){const t=this.cancel=u.bind(this.token=new h(f));null!=e&&e.forEach((e=>{const r=e.reason;if(void 0!==r)return t(r),!1;e.addHandler(t)}))}class h{static from(e){if(h.isCancelToken(e))return e;const t=new h(f);return e.addEventListener("abort",u.bind(t)),t}static isCancelToken(e){return null!=e&&e[c]===a}static source(e){return new p(e)}constructor(e){this._handlers=void 0,this._promise=void 0,this._reason=void 0,this._resolve=void 0,this.onabort=void 0,e!==f&&e(u.bind(this))}get promise(){let e=this._promise;if(void 0===e){const t=this._reason;e=this._promise=void 0!==t?Promise.resolve(t):new Promise((e=>{this._resolve=e}))}return e}get reason(){return this._reason}get requested(){return void 0!==this._reason}addHandler(e){let t=this._handlers;if(void 0===t){if(this.requested)throw new TypeError("cannot add a handler to an already canceled token");t=this._handlers=[]}return t.push(e),l.bind(this,e)}throwIfRequested(){const e=this._reason;if(void 0!==e)throw e}get[c](){return a}get aborted(){return this.requested}addEventListener(e,t){if("abort"!==e)return;const r={type:"abort"},n="function"==typeof t?()=>t(r):()=>t.handleEvent(r);n.listener=t,this.addHandler(n)}removeEventListener(e,t){if("abort"!==e)return;const r=this._handlers;if(void 0!==r){const e=r.findIndex((e=>e.listener===t));-1!==e&&r.splice(e,1)}}}u.call(h.canceled=new h(f)),h.none=new h(f),h.none.addHandler=function(e){return i},h.none._promise={catch(){return this},then(){return this}},t.exports=h},{"./Cancel":1,"./_noop":13,"./_symbols":17,"./defer":23,"./isPromise":36}],3:[function(e,t,r){"use strict";const n=e("./_evalDisposable"),o=e("./_isDisposable"),s=e("./_finally"),i=e("./_setFunctionNameAndLength"),c=e("./wrapApply"),a=e("./wrapCall");class u{constructor(e,t){if("function"!=typeof e)throw new Error("dispose must be a function");this._dispose=e,this._value=t}get value(){if(void 0===this._dispose)throw new TypeError("this disposable has already been disposed");return this._value}dispose(){if(void 0===this._dispose)throw new TypeError("this disposable has already been disposed");const e=this._dispose;return this._dispose=this._value=void 0,e()}}t.exports=u,u.all=function(e){let t=[];const r=()=>{const e=t;t=void 0,e.forEach((e=>e.dispose()))},s=e=>void 0===t?o(e)&&e.dispose():o(e)?(t.push(e),e.value):e,i=e=>{if(void 0!==t)throw r(),e};return Promise.all(Array.from(e,(e=>n(e).then(s,i)))).then((e=>new u(r,e)))};const l=e("./_ExitStack");u.factory=e=>i((function(){const t=e.apply(this,arguments),r=new l,s=r.dispose,i=r.value,c=e=>o(e)?p(i.enter(e)):e,f=({value:e})=>n(e).then(c),p=e=>a(t.next,e,t).then(f);return p().then((e=>new u((()=>a(t.return,void 0,t).then(s)),e)),(e=>{const t=()=>{throw e};return s().then(t,t)}))}),e.name,e.length);const f=e=>{const t=new l,r=t.dispose,o=t.value,i=e=>u(o.enter(e)),c=e=>e.done?e.value:n(e.value).then(i),u=t=>a(e.next,t,e).then(c);return s(u(),r)};u.use=function(){let e=arguments.length-1;if(e<0)throw new TypeError("Disposable.use expects at least 1 argument");const t=arguments[e];if(0===e)return new Promise((e=>e(t.call(this)))).then(f);let r;const n=!Array.isArray(r=arguments[0]);return n?r=Array.prototype.slice.call(arguments,0,e):e=r.length,u.all(r).then((e=>s((n?c:a)(t,e.value,this),(()=>e.dispose()))))},u.wrap=e=>function(){return u.use((()=>e.apply(this,arguments)))}},{"./_ExitStack":5,"./_evalDisposable":6,"./_finally":7,"./_isDisposable":9,"./_setFunctionNameAndLength":16,"./wrapApply":52,"./wrapCall":53}],4:[function(e,t,r){"use strict";const n=e("make-error").BaseError;t.exports=class extends n{constructor(){super("operation timed out")}}},{"make-error":38}],5:[function(e,t,r){"use strict";const n=e("./_isDisposable"),o=e("./_resolve");t.exports=class{constructor(){this._disposables=[];const e=()=>{const t=this._disposables.pop();return void 0!==t?o(t.dispose()).then(e):Promise.resolve()};return{dispose:e,value:this}}enter(e){if(!n(e))throw new TypeError("not a disposable");return this._disposables.push(e),e.value}}},{"./_isDisposable":9,"./_resolve":15}],6:[function(e,t,r){"use strict";const n=e("./try");t.exports=e=>"function"==typeof e?n(e):Promise.resolve(e)},{"./try":50}],7:[function(e,t,r){"use strict";t.exports=(e,t)=>e.then(t,t).then((()=>e))},{}],8:[function(e,t,r){"use strict";t.exports=e=>e},{}],9:[function(e,t,r){"use strict";t.exports=e=>null!=e&&"function"==typeof e.dispose},{}],10:[function(e,t,r){"use strict";t.exports=e=>e instanceof ReferenceError||e instanceof SyntaxError||e instanceof TypeError},{}],11:[function(e,t,r){"use strict";const n=e("./_noop"),o=e("./_once");t.exports=(e,t,r)=>{const s=t.addEventListener||t.addListener||t.on;if(void 0===s)throw new Error("cannot register event listener");const i=t.removeEventListener||t.removeListener||t.off,c=[];let a=n;return void 0!==i&&(a=o((()=>{for(let e=0,r=c.length;e<r;e+=2)i.call(t,c[e],c[e+1])})),e.promise.then(a)),r?(e,r)=>{function n(){a();const t=Array.prototype.slice.call(arguments);t.args=t,t.event=t.name=e,r(t)}c.push(e,n),s.call(t,e,n)}:(e,r)=>{const n=e=>{a(),r(e)};c.push(e,n),s.call(t,e,n)}}},{"./_noop":13,"./_once":14}],12:[function(e,t,r){"use strict";const n=e("./_isProgrammerError");t.exports=function e(t,r){if(void 0===t)return!n(r);const o=typeof t;if("boolean"===o)return t;if("function"===o)return t===Error||t.prototype instanceof Error?r instanceof t:t(r);if(Array.isArray(t)){const n=t.length;for(let o=0;o<n;++o)if(e(t[o],r))return!0;return!1}if(null!=r&&"object"===o){for(const e in t)if(hasOwnProperty.call(t,e)&&r[e]!==t[e])return!1;return!0}}},{"./_isProgrammerError":10}],13:[function(e,t,r){"use strict";t.exports=Function.prototype},{}],14:[function(e,t,r){"use strict";t.exports=e=>{let t;return function(){return void 0!==e&&(t=e.apply(this,arguments),e=void 0),t}}},{}],15:[function(e,t,r){"use strict";const n=e("./isPromise");t.exports=e=>n(e)?e:Promise.resolve(e)},{"./isPromise":36}],16:[function(e,t,r){"use strict";t.exports=(()=>{const t=Object.defineProperties;try{const e=t((function(){}),{length:{value:2},name:{value:"foo"}});if(2===e.length&&"foo"===e.name)return(e,r,n)=>t(e,{length:{configurable:!0,value:n>0?n:0},name:{configurable:!0,value:r}})}catch(e){}return e("./_identity")})()},{"./_identity":8}],17:[function(e,t,r){"use strict";const n="function"==typeof Symbol?e=>{const t=Symbol[e];return void 0!==t?t:`@@${e}`}:e=>`@@${e}`;r.$$iterator=n("iterator"),r.$$toStringTag=n("toStringTag")},{}],18:[function(e,t,r){"use strict";if("function"!=typeof Promise||"function"!=typeof Promise.reject||"function"!=typeof Promise.resolve)throw new Error("a standard Promise implementation is required (https://github.com/JsCommunity/promise-toolbox#usage)");const n=e("./isPromise"),o=e("./_symbols").$$iterator,s=r.forArray=(e,t)=>{const r=e.length;for(let n=0;n<r;++n)t(e[n],n,e)};r.forIn=(e,t)=>{for(const r in e)t(e[r],r,e)};const i=r.forIterable=(e,t)=>{const r=e[o]();let n;for(;!(n=r.next()).done;)t(n.value,void 0,e)},c=Object.prototype.hasOwnProperty,a=r.forOwn=(e,t)=>{for(const r in e)c.call(e,r)&&t(e[r],r,e)},u=r.forEach=(e,t)=>{return Array.isArray(e)?s(e,t):null!=(r=e)&&"function"==typeof r[o]?i(e,t):l(e)?s(e,t):a(e,t);var r},l=r.isArrayLike=e=>"function"!=typeof e&&null!=e&&(e=>"number"==typeof e&&e>=0&&e<1/0&&Math.floor(e)===e)(e.length);r.makeAsyncIterator=e=>{const t=(r,o)=>{if(n(r))return r.then((e=>t(e,o)));let s=Promise.resolve();return e(r,((e,t)=>{s=n(e)?s.then((()=>e.then((e=>o(e,t,r))))):s.then((()=>o(e,t,r)))})),s};return t},r.map=(e,t)=>{const r=[];return u(e,((e,n,o)=>{r.push(t(e,n,o))})),r},r.mapAuto=(e,t)=>{const r=l(e)?new Array(e.length):Object.create(null);return void 0!==t&&u(e,((e,n,o)=>{r[n]=t(e,n,o)})),r}},{"./_symbols":17,"./isPromise":36}],19:[function(e,t,r){"use strict";t.exports=function(e){return"function"==typeof e&&this.then((t=>e(void 0,t)),e),this}},{}],20:[function(e,t,r){"use strict";const n=e("./_identity"),o=e("./isPromise"),s=e("./_resolve"),i=Function.prototype;function c(e,t){let r;try{r=this._iterator[e](t)}catch(e){return this.finally(),this._reject(e)}t=r.value,r.done?(this.finally(),this._resolve(t)):this.toPromise(t).then(this.next,this._throw)}function a(e,t,r){this._iterator=e,this._reject=r,this._resolve=t,this._throw=c.bind(this,"throw"),this.next=c.bind(this,"next")}a.prototype.finally=i,a.prototype.toPromise=s;const u=e=>function(){return new Promise(((t,r)=>new a(e.apply(this,arguments),t,r).next()))};function l(e){a.apply(this,[].slice.call(arguments,1)),this._cancelToken=e,this._onCancel=i,this.finally=e.addHandler((e=>(this._onCancel(e),new Promise((e=>{this.finally=e})))))}Object.setPrototypeOf(l.prototype,Object.getPrototypeOf(a.prototype)).toPromise=function(e){if(Array.isArray(e))return s(e[0]);const t=this._cancelToken;return t.requested?Promise.reject(t.reason):o(e)?new Promise(((t,r)=>{e.then(t,r),this._onCancel=r})):Promise.resolve(e)},u.cancelable=(e,t=n)=>function(){const r=t.apply(this,arguments);return r.requested?Promise.reject(r.reason):new Promise(((t,n)=>{new l(r,e.apply(this,arguments),t,n).next()}))},t.exports=u},{"./_identity":8,"./_resolve":15,"./isPromise":36}],21:[function(e,t,r){"use strict";const n=e("./_setFunctionNameAndLength"),o=e("./CancelToken"),s=o.isCancelToken,i=o.source;t.exports=(e,t,r)=>{const o=void 0!==r?r.value:e,c=n((function(){const e=arguments.length;if(0!==e&&s(arguments[0]))return o.apply(this,arguments);const t=i(),r=t.cancel,n=t.token,c=new Array(e+1);c[0]=n;for(let t=0;t<e;++t)c[t+1]=arguments[t];const a=o.apply(this,c);return a.cancel=r,a}),o.name,o.length-1);return void 0!==r?(r.value=c,r):c}},{"./CancelToken":2,"./_setFunctionNameAndLength":16}],22:[function(e,t,r){"use strict";const n=e("./_matchError");function o(e,t,r){return n(e,r)?t(r):this}t.exports=function(){let e,t=arguments.length;return 0===t||"function"!=typeof(e=arguments[--t])?this:this.then(void 0,o.bind(this,0===t?void 0:1===t?arguments[0]:Array.prototype.slice.call(arguments,0,t),e))}},{"./_matchError":12}],23:[function(e,t,r){"use strict";t.exports=()=>{let e,t;return{promise:new Promise(((r,n)=>{e=r,t=n})),reject:t,resolve:e}}},{}],24:[function(e,t,r){"use strict";const n=e("./isPromise");t.exports=function(e){const t=2===arguments.length?arguments[1]:this;if(n(t))return t.then((t=>new Promise((r=>{setTimeout(r,e,t)}))));let r;const o=new Promise((n=>{r=setTimeout(n,e,t)}));return o.unref=()=>(null!=r&&"function"==typeof r.unref&&r.unref(),o),o}},{"./isPromise":36}],25:[function(e,t,r){"use strict";t.exports=function(e){return this.then(e,e).then((()=>this))}},{}],26:[function(e,t,r){"use strict";t.exports=e("./makeAsyncIterator")(e("./_utils").forArray)},{"./_utils":18,"./makeAsyncIterator":37}],27:[function(e,t,r){"use strict";t.exports=e("./makeAsyncIterator")(e("./_utils").forEach)},{"./_utils":18,"./makeAsyncIterator":37}],28:[function(e,t,r){"use strict";t.exports=e("./makeAsyncIterator")(e("./_utils").forIn)},{"./_utils":18,"./makeAsyncIterator":37}],29:[function(e,t,r){"use strict";t.exports=e("./makeAsyncIterator")(e("./_utils").forIterable)},{"./_utils":18,"./makeAsyncIterator":37}],30:[function(e,t,r){"use strict";t.exports=e("./makeAsyncIterator")(e("./_utils").forOwn)},{"./_utils":18,"./makeAsyncIterator":37}],31:[function(e,t,r){"use strict";function n(e,t,r,n){t.push(((e,t)=>null!=e&&!1!==e?n(e):r(t))),e.apply(this,t)}t.exports=function(e,...t){return new Promise(n.bind(this,"function"==typeof e?e:this[e],t))}},{}],32:[function(e,t,r){"use strict";const n=e("./cancelable"),o=e("./_makeEventAdder"),s=n(((e,t,r,n={})=>new Promise(((s,i)=>{const c=o(e,t,n.array);if(c(r,s),!n.ignoreErrors){const e=n.error,t=void 0===e?"error":e;t!==r&&c(t,i)}}))));t.exports=s},{"./_makeEventAdder":11,"./cancelable":21}],33:[function(e,t,r){"use strict";const n=e("./cancelable"),o=e("./_makeEventAdder"),s=e("./_utils").forArray,i=n(((e,t,r,n=["error"])=>new Promise(((i,c)=>{const a=o(e,t,!0);s(r,(e=>a(e,i))),s(n,(e=>a(e,c)))}))));t.exports=i},{"./_makeEventAdder":11,"./_utils":18,"./cancelable":21}],34:[function(e,t,r){"use strict";const n=e("./_isProgrammerError"),o=e=>{if(n(e))throw e};t.exports=function(){return this.then(void 0,o)}},{"./_isProgrammerError":10}],35:[function(e,t,r){"use strict";r.pAsCallback=r.asCallback=e("./asCallback"),r.pAsyncFn=r.asyncFn=e("./asyncFn"),r.pCancel=r.Cancel=e("./Cancel"),r.pCancelable=r.cancelable=e("./cancelable"),r.pCancelToken=r.CancelToken=e("./CancelToken"),r.pCatch=r.catch=e("./catch"),r.pDefer=r.defer=e("./defer"),r.pDelay=r.delay=e("./delay"),r.pDisposable=r.Disposable=e("./Disposable"),r.pFinally=r.finally=e("./finally"),r.pForArray=r.forArray=e("./forArray"),r.pForEach=r.forEach=e("./forEach"),r.pForIn=r.forIn=e("./forIn"),r.pForIterable=r.forIterable=e("./forIterable"),r.pForOwn=r.forOwn=e("./forOwn"),r.pFromCallback=r.fromCallback=e("./fromCallback"),r.pFromEvent=r.fromEvent=e("./fromEvent"),r.pFromEvents=r.fromEvents=e("./fromEvents"),r.pIgnoreErrors=r.ignoreErrors=e("./ignoreErrors"),r.pIsPromise=r.isPromise=e("./isPromise"),r.pMakeAsyncIterator=r.makeAsyncIterator=e("./makeAsyncIterator"),r.pNodeify=r.nodeify=e("./nodeify"),r.pPipe=r.pipe=e("./pipe"),r.pPromisify=r.promisify=e("./promisify"),r.pPromisifyAll=r.promisifyAll=e("./promisifyAll"),r.pReflect=r.reflect=e("./reflect"),r.pRetry=r.retry=e("./retry"),r.pSome=r.some=e("./some"),r.pSuppressUnhandledRejections=r.suppressUnhandledRejections=e("./suppressUnhandledRejections"),r.pTap=r.tap=e("./tap"),r.pTapCatch=r.tapCatch=e("./tapCatch"),r.pTimeout=r.timeout=e("./timeout"),r.pTimeoutError=r.TimeoutError=e("./TimeoutError"),r.pTry=r.try=e("./try"),r.pUnpromisify=r.unpromisify=e("./unpromisify"),r.pWrapApply=r.wrapApply=e("./wrapApply"),r.pWrapCall=r.wrapCall=e("./wrapCall")},{"./Cancel":1,"./CancelToken":2,"./Disposable":3,"./TimeoutError":4,"./asCallback":19,"./asyncFn":20,"./cancelable":21,"./catch":22,"./defer":23,"./delay":24,"./finally":25,"./forArray":26,"./forEach":27,"./forIn":28,"./forIterable":29,"./forOwn":30,"./fromCallback":31,"./fromEvent":32,"./fromEvents":33,"./ignoreErrors":34,"./isPromise":36,"./makeAsyncIterator":37,"./nodeify":39,"./pipe":40,"./promisify":41,"./promisifyAll":42,"./reflect":43,"./retry":44,"./some":45,"./suppressUnhandledRejections":46,"./tap":47,"./tapCatch":48,"./timeout":49,"./try":50,"./unpromisify":51,"./wrapApply":52,"./wrapCall":53}],36:[function(e,t,r){"use strict";t.exports=e=>null!=e&&"function"==typeof e.then},{}],37:[function(e,t,r){"use strict";const n=e("./_noop"),o=e("./_utils").makeAsyncIterator;t.exports=e=>{const t=o(e);return function(e){return t(this,e).then(n)}}},{"./_noop":13,"./_utils":18}],38:[function(e,t,r){"use strict";var n="undefined"!=typeof Reflect?Reflect.construct:void 0,o=Object.defineProperty,s=Error.captureStackTrace;function i(e){void 0!==e&&o(this,"message",{configurable:!0,value:e,writable:!0});var t=this.constructor.name;void 0!==t&&t!==this.name&&o(this,"name",{configurable:!0,value:t,writable:!0}),s(this,this.constructor)}void 0===s&&(s=function(e){var t=new Error;o(e,"stack",{configurable:!0,get:function(){var e=t.stack;return o(this,"stack",{configurable:!0,value:e,writable:!0}),e},set:function(t){o(e,"stack",{configurable:!0,value:t,writable:!0})}})}),i.prototype=Object.create(Error.prototype,{constructor:{configurable:!0,value:i,writable:!0}});var c=function(){function e(e,t){return o(e,"name",{configurable:!0,value:t})}try{var t=function(){};if(e(t,"foo"),"foo"===t.name)return e}catch(e){}}();r=t.exports=function(e,t){if(null==t||t===Error)t=i;else if("function"!=typeof t)throw new TypeError("super_ should be a function");var r;if("string"==typeof e)r=e,e=void 0!==n?function(){return n(t,arguments,this.constructor)}:function(){t.apply(this,arguments)},void 0!==c&&(c(e,r),r=void 0);else if("function"!=typeof e)throw new TypeError("constructor should be either a string or a function");e.super_=e.super=t;var o={constructor:{configurable:!0,value:e,writable:!0}};return void 0!==r&&(o.name={configurable:!0,value:r,writable:!0}),e.prototype=Object.create(t.prototype,o),e},r.BaseError=i},{}],39:[function(e,t,r){"use strict";const n=e("./_setFunctionNameAndLength"),o=e("./wrapApply"),s=Array.prototype.slice;t.exports=e=>n((function(){const t=arguments.length-1;let r;if(t<0||"function"!=typeof(r=arguments[t]))throw new TypeError("missing callback");const n=s.call(arguments,0,t);o(e,n).then((e=>r(void 0,e)),r)}),e.name,e.length+1)},{"./_setFunctionNameAndLength":16,"./wrapApply":52}],40:[function(e,t,r){"use strict";const n=Array.isArray,o=Array.prototype.slice,s=(e,t)=>e.then(t);t.exports=function(e){return n(e)||(e=o.call(arguments)),"function"!=typeof e[0]?(e[0]=Promise.resolve(e[0]),e.reduce(s)):t=>e.reduce(s,Promise.resolve(t))}},{}],41:[function(e,t,r){"use strict";const n=e("./_setFunctionNameAndLength");t.exports=(e,t)=>n((function(){const r=arguments.length,n=new Array(r+1);for(let e=0;e<r;++e)n[e]=arguments[e];return new Promise(((o,s)=>{n[r]=(e,t)=>null!=e&&!1!==e?s(e):o(t),e.apply(void 0===t?this:t,n)}))}),e.name,e.length-1)},{"./_setFunctionNameAndLength":16}],42:[function(e,t,r){"use strict";const n=e("./promisify"),o=e("./_utils").forIn,s=(e,t)=>!(t.endsWith("Sync")||t.endsWith("Async"))&&t;t.exports=(e,{mapper:t=s,target:r={},context:i=e}={})=>(o(e,((o,s)=>{let c;"function"==typeof o&&(c=t(o,s,e))&&(r[c]=n(o,i))})),r)},{"./_utils":18,"./promisify":41}],43:[function(e,t,r){"use strict";const n=()=>!1,o=()=>!0,s=(i={isFulfilled:o,isPending:n,isRejected:n,reason:()=>{throw new Error("no reason, the promise has resolved")}},e=>({__proto__:i,value:()=>e}));var i;const c=(e=>t=>({__proto__:e,reason:()=>t}))({isFulfilled:n,isPending:n,isRejected:o,value:()=>{throw new Error("no value, the promise has rejected")}});t.exports=function(){return this.then(s,c)}},{}],44:[function(e,t,r){"use strict";const n=e("./_matchError"),o=e("./_noop"),s=e("./_setFunctionNameAndLength");function i(e,{delay:t,delays:r,onRetry:s=o,retries:i,tries:a,when:u}={},l){let f;if(void 0!==r){if(void 0!==t||void 0!==a||void 0!==i)throw new TypeError("delays is incompatible with delay, tries and retries");const e=r[Symbol.iterator]();f=()=>{const r=e.next(),n=r.done,o=r.value;return!n&&(t=o,!0)}}else{if(void 0===a)a=void 0!==i?i+1:10;else if(void 0!==i)throw new TypeError("retries and tries options are mutually exclusive");void 0===t&&(t=1e3),f=()=>0!=--a}u=n.bind(void 0,u);let p=0;const h=e=>setTimeout(e,t),d=()=>new Promise(h),y=r=>{if(r instanceof c)throw r.error;if(u(r)&&f()){let n=Promise.resolve(s.call({arguments:l,attemptNumber:p++,delay:t,fn:e,this:this},r));return 0!==t&&(n=n.then(d)),n.then(v)}throw r},m=t=>t(e.apply(this,l)),v=()=>new Promise(m).catch(y);return v()}function c(e){this.error=e}t.exports=i,i.bail=function(e){throw new c(e)},i.wrap=function(e,t){const r="function"!=typeof t?()=>t:t;return s((function(){return i.call(this,e,r.apply(this,arguments),Array.from(arguments))}),e.name,e.length)}},{"./_matchError":12,"./_noop":13,"./_setFunctionNameAndLength":16}],45:[function(e,t,r){"use strict";const n=e("./_resolve"),o=e("./_utils").forEach;t.exports=function(e){return n(this).then((t=>((e,t)=>new Promise(((r,n)=>{let s=[],i=[];const c=e=>{s&&(s.push(e),0==--t&&(r(s),s=i=void 0))};let a=-t;const u=e=>{s&&(i.push(e),0==--a&&(n(i),s=i=void 0))};o(e,(e=>{++a,r(e).then(c,u)}))})))(t,e)))}},{"./_resolve":15,"./_utils":18}],46:[function(e,t,r){"use strict";const n=e("./_noop");t.exports=function(){const e=this.suppressUnhandledRejections;return"function"==typeof e?e.call(this):this.then(void 0,n),this}},{"./_noop":13}],47:[function(e,t,r){"use strict";t.exports=function(e,t){return this.then(e,t).then((()=>this))}},{}],48:[function(e,t,r){"use strict";t.exports=function(e){return this.then(void 0,e).then((()=>this))}},{}],49:[function(e,t,r){"use strict";const n=e("./TimeoutError");t.exports=function(e,t){return 0===e?this:(void 0===t&&(t=new n),new Promise(((r,n)=>{let o=setTimeout((()=>{if(o=void 0,"function"==typeof this.cancel&&this.cancel(),"function"==typeof t)try{r(t())}catch(e){n(e)}else n(t)}),e);this.then((e=>{void 0!==o&&clearTimeout(o),r(e)}),(e=>{void 0!==o&&clearTimeout(o),n(e)}))})))}},{"./TimeoutError":4}],50:[function(e,t,r){"use strict";const n=e("./_resolve");t.exports=function(e){try{return n(e())}catch(e){return Promise.reject(e)}}},{"./_resolve":15}],51:[function(e,t,r){"use strict";const n=e("./_setFunctionNameAndLength");t.exports=function(){const e=this;return n((function(){const t=arguments.length-1;let r;if(t<0||"function"!=typeof(r=arguments[t]))throw new Error("missing callback");const n=new Array(t);for(let e=0;e<t;++e)n[e]=arguments[e];e.apply(this,n).then((e=>r(void 0,e)),(e=>r(e)))}),e.name,e.length+1)}},{"./_setFunctionNameAndLength":16}],52:[function(e,t,r){"use strict";const n=e("./_resolve");t.exports=(e,t,r)=>{try{return n(e.apply(r,t))}catch(e){return Promise.reject(e)}}},{"./_resolve":15}],53:[function(e,t,r){"use strict";const n=e("./_resolve");t.exports=(e,t,r)=>{try{return n(e.call(r,t))}catch(e){return Promise.reject(e)}}},{"./_resolve":15}]},{},[35])(35)}));
"use strict";
var setFunctionNameAndLength = require("./_setFunctionNameAndLength");
const setFunctionNameAndLength = require("./_setFunctionNameAndLength");
module.exports = function unpromisify() {
var fn = this;
const fn = this;
return setFunctionNameAndLength(function () {
var n = arguments.length - 1;
var cb;
const n = arguments.length - 1;
let cb;

@@ -15,14 +15,10 @@ if (n < 0 || typeof (cb = arguments[n]) !== "function") {

var args = new Array(n);
const args = new Array(n);
for (var i = 0; i < n; ++i) {
for (let i = 0; i < n; ++i) {
args[i] = arguments[i];
}
fn.apply(this, args).then(function (result) {
return cb(undefined, result);
}, function (reason) {
return cb(reason);
});
fn.apply(this, args).then(result => cb(undefined, result), reason => cb(reason));
}, fn.name, fn.length + 1);
};
"use strict";
var resolve = require("./_resolve");
const resolve = require("./_resolve");
var wrapApply = function wrapApply(fn, args, thisArg) {
const wrapApply = (fn, args, thisArg) => {
try {

@@ -7,0 +7,0 @@ return resolve(fn.apply(thisArg, args));

"use strict";
var resolve = require("./_resolve");
const resolve = require("./_resolve");
var wrapCall = function wrapCall(fn, arg, thisArg) {
const wrapCall = (fn, arg, thisArg) => {
try {

@@ -7,0 +7,0 @@ return resolve(fn.call(thisArg, arg));

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc