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.11.0 to 0.12.0

_matchError.js

14

_makeEventAdder.js
"use strict";
var noop = require('./_noop');
var noop = require("./_noop");
var once = require('./_once');
var once = require("./_once");

@@ -11,3 +11,3 @@ module.exports = function ($cancelToken, emitter, arrayArg) {

if (add === undefined) {
throw new Error('cannot register event listener');
throw new Error("cannot register event listener");
}

@@ -31,9 +31,3 @@

clean();
var length = arguments.length;
var args = new Array(length);
for (var i = 0; i < length; ++i) {
args[i] = arguments[i];
}
var args = Array.prototype.slice.call(arguments);
args.event = event;

@@ -40,0 +34,0 @@ cb(args);

"use strict";
var isPromise = require('./isPromise');
var isPromise = require("./isPromise");

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

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

name: {
value: 'foo'
value: "foo"
}
});
if (f.length === 2 && f.name === 'foo') {
if (f.length === 2 && f.name === "foo") {
return function (fn, name, length) {

@@ -22,3 +22,3 @@ return _defineProperties(fn, {

configurable: true,
value: length
value: length > 0 ? length : 0
},

@@ -34,4 +34,4 @@ name: {

return require('./_identity');
return require("./_identity");
}();
//# sourceMappingURL=_setFunctionNameAndLength.js.map
"use strict";
var getSymbol = typeof Symbol === 'function' ? function (name) {
var getSymbol = typeof Symbol === "function" ? function (name) {
var symbol = Symbol[name];

@@ -9,4 +9,4 @@ return symbol !== undefined ? symbol : "@@" + name;

};
exports.$$iterator = getSymbol('iterator');
exports.$$toStringTag = getSymbol('toStringTag');
exports.$$iterator = getSymbol("iterator");
exports.$$toStringTag = getSymbol("toStringTag");
//# sourceMappingURL=_symbols.js.map
"use strict";
if (typeof Promise !== 'function' || typeof Promise.reject !== 'function' || typeof Promise.resolve !== 'function') {
throw new Error('a standard Promise implementation is required (https://github.com/JsCommunity/promise-toolbox#usage)');
if (typeof Promise !== "function" || typeof Promise.reject !== "function" || typeof Promise.resolve !== "function") {
throw new Error("a standard Promise implementation is required (https://github.com/JsCommunity/promise-toolbox#usage)");
}
var isPromise = require('./isPromise');
var isPromise = require("./isPromise");
var _require = require('./_symbols'),
var _require = require("./_symbols"),
$$iterator = _require.$$iterator;

@@ -28,11 +28,2 @@

exports.endsWith = function (str, suffix, pos) {
if (pos === void 0) {
pos = str.length;
}
pos -= suffix.length;
return pos >= 0 && str.indexOf(suffix, pos) === pos;
};
var forArray = exports.forArray = function (array, iteratee) {

@@ -72,21 +63,15 @@ var length = array.length;

var isIterable = function isIterable(value) {
return value != null && typeof value[$$iterator] === 'function';
return value != null && typeof value[$$iterator] === "function";
};
var forEach = exports.forEach = function (collection, iteratee) {
return isArray(collection) ? forArray(collection, iteratee) : isIterable(collection) ? forIterable(collection, iteratee) : isArrayLike(collection) ? forArray(collection, iteratee) : forOwn(collection, iteratee);
return Array.isArray(collection) ? forArray(collection, iteratee) : isIterable(collection) ? forIterable(collection, iteratee) : isArrayLike(collection) ? forArray(collection, iteratee) : forOwn(collection, iteratee);
};
var _Array$isArray = Array.isArray,
isArray = _Array$isArray === void 0 ? function (value) {
return value instanceof Array;
} : _Array$isArray;
exports.isArray = isArray;
var isLength = function isLength(value) {
return typeof value === 'number' && value >= 0 && value < Infinity && Math.floor(value) === value;
return 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);
return typeof value !== "function" && value != null && isLength(value.length);
};

@@ -93,0 +78,0 @@

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

'use strict'
"use strict";
const NODE_ENV = process.env.NODE_ENV || 'development'
const __PROD__ = NODE_ENV === 'production'
const __TEST__ = NODE_ENV === 'test'
const NODE_ENV = process.env.NODE_ENV || "development";
const __PROD__ = NODE_ENV === "production";
const __TEST__ = NODE_ENV === "test";
const pkg = require('./package')
const pkg = require("./package");
const plugins = {}
const plugins = {};
const presets = {
'@babel/preset-env': {
"@babel/preset-env": {
debug: !__TEST__,
loose: true,
targets: (() => {
let node = (pkg.engines || {}).node
let node = (pkg.engines || {}).node;
if (node !== undefined) {
const trimChars = '^=>~'
const trimChars = "^=>~";
while (trimChars.includes(node[0])) {
node = node.slice(1)
node = node.slice(1);
}
}
return { browsers: pkg.browserslist, node }
return { browsers: pkg.browserslist, node };
})(),
},
}
};
Object.keys(pkg.devDependencies || {}).forEach(name => {
if (!(name in presets) && /@babel\/plugin-.+/.test(name)) {
plugins[name] = {}
plugins[name] = {};
} else if (!(name in presets) && /@babel\/preset-.+/.test(name)) {
presets[name] = {}
presets[name] = {};
}
})
});

@@ -41,2 +41,2 @@ module.exports = {

presets: Object.keys(presets).map(preset => [preset, presets[preset]]),
}
};
module.exports = {
extends: ['standard'],
parser: 'babel-eslint',
extends: [
// standard configuration
"standard",
// https://github.com/mysticatea/eslint-plugin-node#-rules
"plugin:node/recommended",
// disable rules handled by prettier
"prettier",
"prettier/standard",
],
parser: "babel-eslint",
rules: {
'comma-dangle': ['error', 'always-multiline'],
'no-var': 'error',
'node/no-extraneous-import': 'error',
'node/no-extraneous-require': 'error',
'prefer-const': 'error',
// prefer let/const over var
"no-var": "error",
// prefer const over let when possible
//
// should be included in standard: https://github.com/standard/eslint-config-standard/pull/133/
"prefer-const": "error",
// detect incorrect import
"node/no-extraneous-import": "error",
"node/no-missing-import": "error",
// uncomment if you are using a builder like Babel
"node/no-unsupported-features/es-syntax": "off",
},
}
};
"use strict";
var isPromise = require('./isPromise');
var isPromise = require("./isPromise");
var _require = require('./_utils'),
var _require = require("./_utils"),
forEach = _require.forEach,

@@ -7,0 +7,0 @@ mapAuto = _require.mapAuto;

"use strict";
module.exports = function asCallback(cb) {
if (typeof cb === 'function') {
if (typeof cb === "function") {
this.then(function (value) {

@@ -6,0 +6,0 @@ return cb(undefined, value);

"use strict";
var toPromise = require('./_resolve');
var toPromise = require("./_resolve");

@@ -25,4 +25,4 @@ function step(key, value) {

this.iterator = iterator;
this.onFulfill = step.bind(this, 'next');
this.onReject = step.bind(this, 'throw');
this.onFulfill = step.bind(this, "next");
this.onReject = step.bind(this, "throw");
this.reject = reject;

@@ -29,0 +29,0 @@ this.resolve = resolve;

@@ -6,6 +6,6 @@ "use strict";

if (message === void 0) {
message = 'this action has been canceled';
message = "this action has been canceled";
}
Object.defineProperty(this, 'message', {
Object.defineProperty(this, "message", {
enumerable: true,

@@ -12,0 +12,0 @@ value: message

"use strict";
var _require = require('./CancelToken'),
var setFunctionNameAndLength = require("./_setFunctionNameAndLength");
var _require = require("./CancelToken"),
isCancelToken = _require.isCancelToken,

@@ -9,4 +11,3 @@ source = _require.source;

var fn = descriptor !== undefined ? descriptor.value : target;
function cancelableWrapper() {
var wrapper = setFunctionNameAndLength(function cancelableWrapper() {
var length = arguments.length;

@@ -32,10 +33,10 @@

return promise;
}
}, fn.name, fn.length - 1);
if (descriptor !== undefined) {
descriptor.value = cancelableWrapper;
descriptor.value = wrapper;
return descriptor;
}
return cancelableWrapper;
return wrapper;
};

@@ -42,0 +43,0 @@

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

var defer = require('./defer');
var defer = require("./defer");
var Cancel = require('./Cancel');
var Cancel = require("./Cancel");
var isPromise = require('./isPromise');
var isPromise = require("./isPromise");
var _require = require('./_symbols'),
var _require = require("./_symbols"),
$$toStringTag = _require.$$toStringTag;
var cancelTokenTag = 'CancelToken';
var cancelTokenTag = "CancelToken";

@@ -126,3 +126,3 @@ function cancel(message) {

if (this.requested) {
throw new TypeError('cannot add a handler to an already canceled token');
throw new TypeError("cannot add a handler to an already canceled token");
}

@@ -129,0 +129,0 @@

"use strict";
var isProgrammerError = require('./_isProgrammerError');
var matchError = require("./_matchError");
var matchError = function matchError(predicate, error) {
if (typeof predicate === 'function') {
return predicate === Error || predicate.prototype instanceof Error ? error instanceof predicate : predicate(error);
}
function handler(predicates, cb, reason) {
return matchError(predicates, reason) ? cb(reason) : this;
}
if (error != null && typeof predicate === 'object') {
for (var key in predicate) {
if (hasOwnProperty.call(predicate, key) && error[key] !== predicate[key]) {
return false;
}
}
return true;
}
};
module.exports = function pCatch() {
var _this = this;
var n = arguments.length;
var cb;
if (n === 0 || typeof (cb = arguments[--n]) !== 'function') {
if (n === 0 || typeof (cb = arguments[--n]) !== "function") {
return this;
}
if (n === 0) {
return this.then(undefined, function (reason) {
return isProgrammerError(reason) ? _this : cb(reason);
});
}
var predicates = new Array(n);
for (var i = 0; i < n; ++i) {
predicates[i] = arguments[i];
}
return this.then(undefined, function (reason) {
for (var _i = 0; _i < n; ++_i) {
if (matchError(predicates[_i], reason)) {
return cb(reason);
}
}
return _this;
});
return this.then(undefined, handler.bind(this, n === 0 ? undefined : n === 1 ? arguments[0] : Array.prototype.slice.call(arguments, 0, n), cb));
};
//# sourceMappingURL=catch.js.map
"use strict";
var isPromise = require('./isPromise');
var isPromise = require("./isPromise");

@@ -5,0 +5,0 @@ module.exports = function delay(ms) {

"use strict";
var Resource = require('./_Resource');
var Resource = require("./_Resource");

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

"use strict";
module.exports = require('./makeAsyncIterator')(require('./_utils').forArray);
module.exports = require("./makeAsyncIterator")(require("./_utils").forArray);
//# sourceMappingURL=forArray.js.map
"use strict";
module.exports = require('./makeAsyncIterator')(require('./_utils').forEach);
module.exports = require("./makeAsyncIterator")(require("./_utils").forEach);
//# sourceMappingURL=forEach.js.map
"use strict";
module.exports = require('./makeAsyncIterator')(require('./_utils').forIn);
module.exports = require("./makeAsyncIterator")(require("./_utils").forIn);
//# sourceMappingURL=forIn.js.map
"use strict";
module.exports = require('./makeAsyncIterator')(require('./_utils').forIterable);
module.exports = require("./makeAsyncIterator")(require("./_utils").forIterable);
//# sourceMappingURL=forIterable.js.map
"use strict";
module.exports = require('./makeAsyncIterator')(require('./_utils').forOwn);
module.exports = require("./makeAsyncIterator")(require("./_utils").forOwn);
//# sourceMappingURL=forOwn.js.map
"use strict";
var cancelable = require('./cancelable');
var cancelable = require("./cancelable");
var makeEventAdder = require('./_makeEventAdder');
var makeEventAdder = require("./_makeEventAdder");

@@ -19,3 +19,3 @@ var fromEvent = cancelable(function ($cancelToken, emitter, event, opts) {

_opts$error = _opts.error,
error = _opts$error === void 0 ? 'error' : _opts$error;
error = _opts$error === void 0 ? "error" : _opts$error;

@@ -22,0 +22,0 @@ if (error !== event) {

"use strict";
var cancelable = require('./cancelable');
var cancelable = require("./cancelable");
var makeEventAdder = require('./_makeEventAdder');
var makeEventAdder = require("./_makeEventAdder");
var _require = require('./_utils'),
var _require = require("./_utils"),
forArray = _require.forArray;

@@ -12,3 +12,3 @@

if (errorEvents === void 0) {
errorEvents = ['error'];
errorEvents = ["error"];
}

@@ -15,0 +15,0 @@

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

@@ -5,0 +5,0 @@ var cb = function cb(error) {

"use strict";
exports.pAll = exports.all = require('./all');
exports.pAsCallback = exports.asCallback = require('./asCallback');
exports.pAsyncFn = exports.asyncFn = require('./asyncFn');
exports.pCancel = exports.Cancel = require('./Cancel');
exports.pCancelable = exports.cancelable = require('./cancelable');
exports.pCancelToken = exports.CancelToken = require('./CancelToken');
exports.pCatch = exports.catch = require('./catch');
exports.pDefer = exports.defer = require('./defer');
exports.pDelay = exports.delay = require('./delay');
exports.pDisposer = exports.disposer = require('./disposer');
exports.pFinally = exports.finally = require('./finally');
exports.pForArray = exports.forArray = require('./forArray');
exports.pForEach = exports.forEach = require('./forEach');
exports.pForIn = exports.forIn = require('./forIn');
exports.pForIterable = exports.forIterable = require('./forIterable');
exports.pForOwn = exports.forOwn = require('./forOwn');
exports.pFromCallback = exports.fromCallback = require('./fromCallback');
exports.pFromEvent = exports.fromEvent = require('./fromEvent');
exports.pFromEvents = exports.fromEvents = require('./fromEvents');
exports.pIgnoreErrors = exports.ignoreErrors = require('./ignoreErrors');
exports.pIsPromise = exports.isPromise = require('./isPromise');
exports.pMakeAsyncIterator = exports.makeAsyncIterator = require('./makeAsyncIterator');
exports.pMap = exports.map = require('./map');
exports.pPromisify = exports.promisify = require('./promisify');
exports.pPromisifyAll = exports.promisifyAll = require('./promisifyAll');
exports.pReflect = exports.reflect = require('./reflect');
exports.pSettle = exports.settle = require('./settle');
exports.pSome = exports.some = require('./some');
exports.pSuppressUnhandledRejections = exports.suppressUnhandledRejections = require('./suppressUnhandledRejections');
exports.pTap = exports.tap = require('./tap');
exports.pTapCatch = exports.tapCatch = require('./tapCatch');
exports.pTimeout = exports.timeout = require('./timeout');
exports.pTimeoutError = exports.TimeoutError = require('./TimeoutError');
exports.pTry = exports.try = require('./try');
exports.pUnpromisify = exports.unpromisify = require('./unpromisify');
exports.pUsing = exports.using = require('./using');
exports.pWrapApply = exports.wrapApply = require('./wrapApply');
exports.pWrapCall = exports.wrapCall = require('./wrapCall');
exports.pAll = exports.all = require("./all");
exports.pAsCallback = exports.asCallback = require("./asCallback");
exports.pAsyncFn = exports.asyncFn = require("./asyncFn");
exports.pCancel = exports.Cancel = require("./Cancel");
exports.pCancelable = exports.cancelable = require("./cancelable");
exports.pCancelToken = exports.CancelToken = require("./CancelToken");
exports.pCatch = exports.catch = require("./catch");
exports.pDefer = exports.defer = require("./defer");
exports.pDelay = exports.delay = require("./delay");
exports.pDisposer = exports.disposer = require("./disposer");
exports.pFinally = exports.finally = require("./finally");
exports.pForArray = exports.forArray = require("./forArray");
exports.pForEach = exports.forEach = require("./forEach");
exports.pForIn = exports.forIn = require("./forIn");
exports.pForIterable = exports.forIterable = require("./forIterable");
exports.pForOwn = exports.forOwn = require("./forOwn");
exports.pFromCallback = exports.fromCallback = require("./fromCallback");
exports.pFromEvent = exports.fromEvent = require("./fromEvent");
exports.pFromEvents = exports.fromEvents = require("./fromEvents");
exports.pIgnoreErrors = exports.ignoreErrors = require("./ignoreErrors");
exports.pIsPromise = exports.isPromise = require("./isPromise");
exports.pMakeAsyncIterator = exports.makeAsyncIterator = require("./makeAsyncIterator");
exports.pMap = exports.map = require("./map");
exports.pPipe = exports.pipe = require("./pipe");
exports.pPromisify = exports.promisify = require("./promisify");
exports.pPromisifyAll = exports.promisifyAll = require("./promisifyAll");
exports.pReflect = exports.reflect = require("./reflect");
exports.pRetry = exports.retry = require("./retry");
exports.pSettle = exports.settle = require("./settle");
exports.pSome = exports.some = require("./some");
exports.pSuppressUnhandledRejections = exports.suppressUnhandledRejections = require("./suppressUnhandledRejections");
exports.pTap = exports.tap = require("./tap");
exports.pTapCatch = exports.tapCatch = require("./tapCatch");
exports.pTimeout = exports.timeout = require("./timeout");
exports.pTimeoutError = exports.TimeoutError = require("./TimeoutError");
exports.pTry = exports.try = require("./try");
exports.pUnpromisify = exports.unpromisify = require("./unpromisify");
exports.pUsing = exports.using = require("./using");
exports.pWrapApply = exports.wrapApply = require("./wrapApply");
exports.pWrapCall = exports.wrapCall = require("./wrapCall");
//# sourceMappingURL=index.js.map
"use strict";
var isPromise = function isPromise(value) {
return value != null && typeof value.then === 'function';
return value != null && typeof value.then === "function";
};

@@ -6,0 +6,0 @@

"use strict";
var noop = require('./_noop');
var noop = require("./_noop");
var _require = require('./_utils'),
var _require = require("./_utils"),
makeAsyncIterator = _require.makeAsyncIterator;

@@ -7,0 +7,0 @@

"use strict";
var defer = require('./defer');
var defer = require("./defer");
var identity = require('./_identity');
var identity = require("./_identity");
var isPromise = require('./isPromise');
var isPromise = require("./isPromise");
var _require = require('./_utils'),
var _require = require("./_utils"),
applyThen = _require.applyThen,

@@ -11,0 +11,0 @@ forEach = _require.forEach;

{
"name": "promise-toolbox",
"version": "0.11.0",
"version": "0.12.0",
"license": "ISC",

@@ -52,2 +52,3 @@ "description": "Essential utils for promises",

"eslint": "^5.0.1",
"eslint-config-prettier": "^4.0.0",
"eslint-config-standard": "^12.0.0",

@@ -60,2 +61,4 @@ "eslint-plugin-import": "^2.8.0",

"jest": "^23.2.0",
"lint-staged": "^8.1.4",
"prettier": "^1.16.4",
"rimraf": "^2.6.2"

@@ -72,3 +75,3 @@ },

"prepublishOnly": "npm run build",
"pretest": "eslint --ignore-path .gitignore --fix src/",
"pretest": "eslint --ignore-path .gitignore src/",
"test": "jest"

@@ -86,5 +89,13 @@ },

"hooks": {
"commit-msg": "npm test"
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.js": [
"prettier --write",
"git add",
"eslint --ignore-pattern '!*'",
"jest --findRelatedTests --passWithNoTests"
]
}
}
"use strict";
var setFunctionNameAndLength = require('./_setFunctionNameAndLength');
var setFunctionNameAndLength = require("./_setFunctionNameAndLength");

@@ -18,3 +18,3 @@ var promisify = function promisify(fn, context) {

args[length] = function (error, result) {
return error ? reject(error) : resolve(result);
return error != null ? reject(error) : resolve(result);
};

@@ -24,3 +24,3 @@

});
}, fn.name, fn.length !== 0 && fn.length - 1);
}, fn.name, fn.length - 1);
};

@@ -27,0 +27,0 @@

"use strict";
var promisify = require('./promisify');
var promisify = require("./promisify");
var _require = require('./_utils'),
endsWith = _require.endsWith,
var _require = require("./_utils"),
forIn = _require.forIn;
var DEFAULT_MAPPER = function DEFAULT_MAPPER(_, name) {
return !(endsWith(name, 'Sync') || endsWith(name, 'Async')) && name;
return !(name.endsWith("Sync") || name.endsWith("Async")) && name;
};

@@ -25,3 +24,3 @@

if (typeof value === 'function' && (newName = mapper(value, name, obj))) {
if (typeof value === "function" && (newName = mapper(value, name, obj))) {
target[newName] = promisify(value, context);

@@ -28,0 +27,0 @@ }

@@ -1,3 +0,5 @@

# promise-toolbox [![Build Status](https://travis-ci.org/JsCommunity/promise-toolbox.png?branch=master)](https://travis-ci.org/JsCommunity/promise-toolbox)
# promise-toolbox
[![Package Version](https://badgen.net/npm/v/promise-toolbox)](https://npmjs.org/package/promise-toolbox) [![Build Status](https://travis-ci.org/JsCommunity/promise-toolbox.png?branch=master)](https://travis-ci.org/JsCommunity/promise-toolbox) [![PackagePhobia](https://badgen.net/packagephobia/install/promise-toolbox)](https://packagephobia.now.sh/result?p=promise-toolbox) [![Latest Commit](https://badgen.net/github/last-commit/JsCommunity/promise-toolbox)](https://github.com/JsCommunity/promise-toolbox/commits/master)
> Essential utils for promises.

@@ -27,2 +29,3 @@

- [isPromise(value)](#ispromisevalue)
- [pipe(fns)](#pipefns)
- [promisify(fn, [ context ]) / promisifyAll(obj)](#promisifyfn--context---promisifyallobj)

@@ -74,3 +77,3 @@ - [try(fn)](#tryfn)

```js
global.Promise = require('bluebird')
global.Promise = require("bluebird");
```

@@ -86,5 +89,5 @@

```js
import * as PT from 'promise-toolbox'
import * as PT from "promise-toolbox";
console.log(PT.isPromise(value))
console.log(PT.isPromise(value));
```

@@ -95,5 +98,5 @@

```js
import { isPromise } from 'promise-toolbox'
import { isPromise } from "promise-toolbox";
console.log(isPromise(value))
console.log(isPromise(value));
```

@@ -105,3 +108,3 @@

```js
import { pCatch, pMap } from 'promise-toolbox'
import { pCatch, pMap } from "promise-toolbox";
```

@@ -113,4 +116,4 @@

```js
import isPromise from 'promise-toolbox/isPromise'
import pCatch from 'promise-toolbox/catch'
import isPromise from "promise-toolbox/isPromise";
import pCatch from "promise-toolbox/catch";
```

@@ -129,3 +132,3 @@

```js
import { CancelToken } from 'promise-toolbox'
import { CancelToken } from "promise-toolbox";
```

@@ -141,8 +144,8 @@

const token = new CancelToken(cancel => {
$('#some-button').on('click', () => cancel('button clicked'))
})
$("#some-button").on("click", () => cancel("button clicked"));
});
```
```js
const { cancel, token } = CancelToken.source()
const { cancel, token } = CancelToken.source();
```

@@ -156,3 +159,3 @@

// `token2` or token3` is, with the same reason.
const { cancel, token } = CancelToken.source([token1, token2, token3])
const { cancel, token } = CancelToken.source([token1, token2, token3]);
```

@@ -172,3 +175,3 @@

if (token.reason) {
console.log('cancelation has been requested', token.reason.message)
console.log("cancelation has been requested", token.reason.message);
}

@@ -178,5 +181,5 @@

try {
token.throwIfRequested()
token.throwIfRequested();
} catch (reason) {
console.log('cancelation has been requested', reason.message)
console.log("cancelation has been requested", reason.message);
}

@@ -186,7 +189,7 @@

token.promise.then(reason => {
console.log('cancelation has been requested', reason.message)
})
console.log("cancelation has been requested", reason.message);
});
// 4.
subtask(token)
subtask(token);
```

@@ -201,22 +204,22 @@

```js
function httpRequest (cancelToken, opts) {
const req = http.request(opts)
req.end()
function httpRequest(cancelToken, opts) {
const req = http.request(opts);
req.end();
cancelToken.addHandler(() => {
req.abort()
req.abort();
// waits for the socket to really close for the cancelation to be
// complete
return fromEvent(req, 'close')
})
return fromEvent(req, 'response')
return fromEvent(req, "close");
});
return fromEvent(req, "response");
}
const { cancel, token } = CancelToken.source()
const { cancel, token } = CancelToken.source();
httpRequest(token, {
hostname: 'example.org',
hostname: "example.org",
}).then(response => {
// do something with the response of the request
})
});

@@ -227,3 +230,3 @@ // wraps with Promise.resolve() because cancel only returns a promise

// the request has been properly canceled
})
});
```

@@ -235,3 +238,3 @@

if (CancelToken.isCancelToken(value)) {
console.log('value is a cancel token')
console.log("value is a cancel token");
}

@@ -249,3 +252,3 @@ ```

```js
import { cancelable, CancelToken } from 'promise-toolbox'
import { cancelable, CancelToken } from "promise-toolbox";

@@ -255,15 +258,15 @@ const asyncFunction = cancelable(async ($cancelToken, a, b) => {

// do stuff regarding the cancelation request.
})
});
// do other stuff.
})
});
// Either a cancel token is passed:
const source = CancelToken.source()
const promise1 = asyncFunction(source.token, 'foo', 'bar')
source.cancel('reason')
const source = CancelToken.source();
const promise1 = asyncFunction(source.token, "foo", "bar");
source.cancel("reason");
// Or the returned promise will have a cancel() method:
const promise2 = asyncFunction('foo', 'bar')
promise2.cancel('reason')
const promise2 = asyncFunction("foo", "bar");
promise2.cancel("reason");
```

@@ -277,3 +280,3 @@

@cancelable
async asyncMethod ($cancelToken, a, b) {
async asyncMethod($cancelToken, a, b) {
// ...

@@ -358,11 +361,11 @@ }

```js
import { defer } from 'promise-toolbox'
import { defer } from "promise-toolbox";
const { promise, resolve } = defer()
const { promise, resolve } = defer();
promise.then(value => {
console.log(value)
})
console.log(value);
});
resolve(3)
resolve(3);
```

@@ -375,7 +378,7 @@

```js
import { fromCallback } from 'promise-toolbox'
import { fromCallback } from "promise-toolbox";
fromCallback(cb => fs.readFile('foo.txt', cb)).then(content => {
console.log(content)
})
fromCallback(cb => fs.readFile("foo.txt", cb)).then(content => {
console.log(content);
});
```

@@ -389,3 +392,3 @@

```js
const promise = fromEvent(emitter, 'foo', {
const promise = fromEvent(emitter, "foo", {
// whether the promise resolves to an array of all the event args

@@ -399,13 +402,13 @@ // instead of simply the first arg

// name of the error event
error: 'error',
})
error: "error",
});
promise.then(
value => {
console.log('foo event was emitted with value', value)
console.log("foo event was emitted with value", value);
},
reason => {
console.error('an error has been emitted', reason)
console.error("an error has been emitted", reason);
}
)
);
```

@@ -422,14 +425,14 @@

```js
fromEvents(emitter, ['foo', 'bar'], ['error1', 'error2']).then(
fromEvents(emitter, ["foo", "bar"], ["error1", "error2"]).then(
values => {
console.log('event %s have been emitted with values', values.event, values)
console.log("event %s have been emitted with values", values.event, values);
},
reasons => {
console.error(
'error event %s has been emitted with errors',
"error event %s has been emitted with errors",
reasons.event,
reasons
)
);
}
)
);
```

@@ -440,9 +443,22 @@

```js
import { isPromise } from 'promise-toolbox'
import { isPromise } from "promise-toolbox";
if (isPromise(foo())) {
console.log('foo() returns a promise')
console.log("foo() returns a promise");
}
```
#### pipe(fns)
> Create a new function from the composition of async functions.
```js
import { pipe } from "promise-toolbox";
const getUserPreferences = pipe(
getUser,
getPreferences
);
```
#### promisify(fn, [ context ]) / promisifyAll(obj)

@@ -454,4 +470,4 @@

```js
import fs from 'fs'
import { promisify, promisifyAll } from 'promise-toolbox'
import fs from "fs";
import { promisify, promisifyAll } from "promise-toolbox";

@@ -461,12 +477,60 @@ // Promisify a single function.

// If possible, the function name is kept and the new length is set.
const readFile = promisify(fs.readFile)
const readFile = promisify(fs.readFile);
// Or all functions (own or inherited) exposed on a object.
const fsPromise = promisifyAll(fs)
const fsPromise = promisifyAll(fs);
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));
```
#### retry(fn, [options])
> Retries an async function when it fails.
```js
import { retry } from "promise-toolbox";
(async () => {
await retry(
async bail => {
const response = await fetch("https://pokeapi.co/api/v2/pokemon/3/");
if (response.status === 500) {
// no need to retry in this case
throw bail(new Error(response.statusText));
}
if (response.status !== 200) {
throw new Error(response.statusText);
}
return response.json();
},
{
// delay before a retry, default to 1000 ms
delay: 2000,
// this function is called before a retry is schedule (before the delay)
//
// it receives the error that triggered the retry
async onRetry(error) {
// …
},
// number of tries including the first one, default to 10
tries: 3,
// predicate when to retry, default on always but programmer errors
// (ReferenceError, SyntaxError and TypeError)
//
// similar to `promise-toolbox/catch`, it can be a constructor, an object,
// a function, or an array of the previous
when: { message: "my error message" },
}
);
})().catch(console.error.bind(console));
```
#### try(fn)

@@ -477,11 +541,11 @@

```js
import PromiseToolbox from 'promise-toolbox'
import PromiseToolbox from "promise-toolbox";
const getUserById = id =>
PromiseToolbox.try(() => {
if (typeof id !== 'number') {
throw new Error('id must be a number')
if (typeof id !== "number") {
throw new Error("id must be a number");
}
return db.getUserById(id)
})
return db.getUserById(id);
});
```

@@ -497,12 +561,12 @@

```js
function getUserById (id) {
if (typeof id !== 'number') {
throw new TypeError('id must be a number')
function getUserById(id) {
if (typeof id !== "number") {
throw new TypeError("id must be a number");
}
return db.getUser(id)
return db.getUser(id);
}
wrapCall(getUserById, 'foo').catch(error => {
wrapCall(getUserById, "foo").catch(error => {
// id must be a number
})
});
```

@@ -518,7 +582,7 @@

```js
const promises = [Promise.resolve('foo'), Promise.resolve('bar')]
const promises = [Promise.resolve("foo"), Promise.resolve("bar")];
promises::all().then(values => {
console.log(values)
})
console.log(values);
});
// → [ 'foo', 'bar' ]

@@ -532,7 +596,7 @@ ```

```js
const promises = [Promise.resolve('foo'), Promise.resolve('bar')]
const promises = [Promise.resolve("foo"), Promise.resolve("bar")];
all.call(promises).then(function(values) {
console.log(values)
})
console.log(values);
});
// → [ 'foo', 'bar' ]

@@ -576,8 +640,8 @@ ```

```js
import { asCallback } from 'promise-toolbox'
import { asCallback } from "promise-toolbox";
// This function can be used either with node-style callbacks or with
// promises.
function getDataFor (input, callback) {
return dataFromDataBase(input)::asCallback(callback)
function getDataFor(input, callback) {
return dataFromDataBase(input)::asCallback(callback);
}

@@ -598,3 +662,3 @@ ```

.then(() => {
return a.b.c.d()
return a.b.c.d();
})

@@ -609,3 +673,3 @@ ::pCatch(TypeError, ReferenceError, reason => {

// Catch any unexpected errors
})
});
```

@@ -620,3 +684,3 @@

```js
console.log(await Promise.resolve('500ms passed')::delay(500))
console.log(await Promise.resolve("500ms passed")::delay(500));
// → 500 ms passed

@@ -628,3 +692,3 @@ ```

```js
console.log(await delay(500, '500ms passed'))
console.log(await delay(500, "500ms passed"));
// → 500 ms passed

@@ -643,8 +707,8 @@ ```

```js
['foo', Promise.resolve('bar')]::forEach(value => {
console.log(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));
});
// →

@@ -660,18 +724,18 @@ // foo

```js
import { ignoreErrors } from 'promise-toolbox'
import { ignoreErrors } from "promise-toolbox";
// will not emit an unhandled rejection error if the file does not
// exist
readFileAsync('foo.txt')
readFileAsync("foo.txt")
.then(content => {
console.log(content)
console.log(content);
})
::ignoreErrors()
::ignoreErrors();
// will emit an unhandled rejection error due to the typo
readFileAsync('foo.txt')
readFileAsync("foo.txt")
.then(content => {
console.lgo(content) // typo
console.lgo(content); // typo
})
::ignoreErrors()
::ignoreErrors();
```

@@ -688,14 +752,14 @@

```js
import { pFinally } from 'promise-toolbox'
import { pFinally } from "promise-toolbox";
function ajaxGetAsync (url) {
function ajaxGetAsync(url) {
return new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest()
xhr.addEventListener('error', reject)
xhr.addEventListener('load', resolve)
xhr.open('GET', url)
xhr.send(null)
const xhr = new XMLHttpRequest();
xhr.addEventListener("error", reject);
xhr.addEventListener("load", resolve);
xhr.open("GET", url);
xhr.send(null);
})::pFinally(() => {
$('#ajax-loader-animation').hide()
})
$("#ajax-loader-animation").hide();
});
}

@@ -710,10 +774,10 @@ ```

```js
import { reflect } from 'promise-toolbox'
import { reflect } from "promise-toolbox";
const inspection = await promise::reflect()
const inspection = await promise::reflect();
if (inspection.isFulfilled()) {
console.log(inspection.value())
console.log(inspection.value());
} else {
console.error(inspection.reason())
console.error(inspection.reason());
}

@@ -727,10 +791,10 @@ ```

```js
import { some } from 'promise-toolbox'
import { some } from "promise-toolbox";
const [first, seconds] = await [
ping('ns1.example.org'),
ping('ns2.example.org'),
ping('ns3.example.org'),
ping('ns4.example.org'),
]::some(2)
ping("ns1.example.org"),
ping("ns2.example.org"),
ping("ns3.example.org"),
ping("ns4.example.org"),
]::some(2);
```

@@ -746,8 +810,8 @@

```js
const promise = getUser()::suppressUnhandledRejections()
$(document).on('ready', () => {
const promise = getUser()::suppressUnhandledRejections();
$(document).on("ready", () => {
promise.catch(error => {
console.error('error while getting user', error)
})
})
console.error("error while getting user", error);
});
});
```

@@ -763,3 +827,3 @@

```js
import { tap } from 'promise-toolbox'
import { tap } from "promise-toolbox";

@@ -769,9 +833,9 @@ // Contrary to .then(), using ::tap() does not change the resolution

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

@@ -792,14 +856,14 @@

```js
import { timeout, TimeoutError } from 'promise-toolbox'
import { timeout, TimeoutError } from "promise-toolbox";
await doLongOperation()::timeout(100, () => {
return doFallbackOperation()
})
return doFallbackOperation();
});
await doLongOperation()::timeout(100)
await doLongOperation()::timeout(100);
await doLongOperation()::timeout(
100,
new Error('the long operation has failed')
)
new Error("the long operation has failed")
);
```

@@ -806,0 +870,0 @@

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

reason: function reason() {
throw new Error('no reason, the promise has resolved');
throw new Error("no reason, the promise has resolved");
}

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

value: function value() {
throw new Error('no value, the promise has rejected');
throw new Error("no value, the promise has rejected");
}

@@ -47,0 +47,0 @@ });

"use strict";
var all = require('./all');
var all = require("./all");
var reflect = require('./reflect');
var reflect = require("./reflect");
var resolve = require('./_resolve');
var resolve = require("./_resolve");

@@ -9,0 +9,0 @@ module.exports = function settle() {

"use strict";
var resolve = require('./_resolve');
var resolve = require("./_resolve");
var _require = require('./_utils'),
var _require = require("./_utils"),
forEach = _require.forEach;

@@ -7,0 +7,0 @@

"use strict";
var noop = require('./_noop');
var noop = require("./_noop");

@@ -8,3 +8,3 @@ module.exports = function suppressUnhandledRejections() {

if (typeof native === 'function') {
if (typeof native === "function") {
native.call(this);

@@ -11,0 +11,0 @@ } else {

"use strict";
var TimeoutError = require('./TimeoutError');
var TimeoutError = require("./TimeoutError");

@@ -20,7 +20,7 @@ module.exports = function timeout(ms, onReject) {

if (typeof _this.cancel === 'function') {
if (typeof _this.cancel === "function") {
_this.cancel();
}
if (typeof onReject === 'function') {
if (typeof onReject === "function") {
try {

@@ -27,0 +27,0 @@ resolve(onReject());

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

var _require = require('make-error'),
var _require = require("make-error"),
BaseError = _require.BaseError;

@@ -13,3 +13,3 @@

function TimeoutError() {
return _BaseError.call(this, 'operation timed out') || this;
return _BaseError.call(this, "operation timed out") || this;
}

@@ -16,0 +16,0 @@

"use strict";
var resolve = require('./_resolve');
var 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._handlers;if(void 0!==d){this._handlers=void 0;for(var e=h(),f=e.promise,g=e.resolve,l=0,m=function(){if(0==--l)return g()},o=0,p=d.length;o<p;++o)try{var n=d[o](b);k(n)&&(++l,n.then(m,m))}catch(a){}if(0!==l)return f}}}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 p(o));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("./_symbols"),m=l.$$toStringTag,n="CancelToken",o={},p=function(){function a(a){this._handlers=void 0,this._promise=void 0,this._reason=void 0,this._resolve=void 0,a!==o&&a(e.bind(this))}a.isCancelToken=function(a){return null!=a&&a[m]===n},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},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:m,get:function(){return n}}]),a}();e.call(p.canceled=new p(o)),p.none=new p(o),b.exports=p},{"./Cancel":1,"./_symbols":12,"./defer":19,"./isPromise":33}],3:[function(a,b){"use strict";function c(a,b){a.prototype=Object.create(b.prototype),a.prototype.constructor=a,a.__proto__=b}var d=a("make-error"),e=d.BaseError;b.exports=function(a){function b(){return a.call(this,"operation timed out")||this}return c(b,a),b}(e)},{"make-error":36}],4:[function(a,b){"use strict";b.exports=function(a,b){this.d=b,this.p=a}},{}],5:[function(a,b){"use strict";b.exports=function(a){return a}},{}],6:[function(a,b){"use strict";b.exports=function(a){return a instanceof ReferenceError||a instanceof SyntaxError||a instanceof TypeError}},{}],7:[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=[],j=c;return void 0!==g&&(j=d(function(){for(var a=0,c=h.length;a<c;a+=2)g.call(b,h[a],h[a+1])}),a.promise.then(j)),e?function(a,c){function d(){j();for(var b=arguments.length,d=Array(b),e=0;e<b;++e)d[e]=arguments[e];d.event=a,c(d)}h.push(a,d),f.call(b,a,d)}:function(a,c){var d=function(a){j(),c(a)};h.push(a,d),f.call(b,a,d)}}},{"./_noop":8,"./_once":9}],8:[function(a,b){"use strict";b.exports=Function.prototype},{}],9:[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}}},{}],10:[function(a,b){"use strict";var c=a("./isPromise");b.exports=function(a){return c(a)?a:Promise.resolve(a)}},{"./isPromise":33}],11:[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:d},name:{configurable:!0,value:c}})}}catch(a){}return a("./_identity")}()},{"./_identity":5}],12:[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")},{}],13:[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;c.applyThen=function(a,b,c,e){var f;try{if(f=a.apply(void 0,b),d(f))return void f.then(c,e)}catch(a){return void e(a)}c(f)},c.endsWith=function(a,b,c){return void 0===c&&(c=a.length),c-=b.length,0<=c&&a.indexOf(b,c)===c};var 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 n(a)?g(a,b):k(a)?h(a,b):p(a)?g(a,b):j(a,b)},m=Array.isArray,n=void 0===m?function(a){return a instanceof Array}:m;c.isArray=n;var o=function(a){return"number"==typeof a&&0<=a&&a<1/0&&Math.floor(a)===a},p=c.isArrayLike=function(a){return"function"!=typeof a&&null!=a&&o(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=p(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":12,"./isPromise":33}],14:[function(a,b){"use strict";var c=a("./isPromise"),d=a("./_utils"),e=d.forEach,f=d.mapAuto,g=function(a,b){return new Promise(function(d,g){var h=f(a,b),i=1,j=function(){if(0==--i){var a=h;h=void 0,d(a)}},k=function(a,b){h&&(h[b]=a,j())},l=function(a){h&&(h=void 0,g(a))};e(b===void 0?a:h,function(a,b){++i,c(a)?a.then(function(a){return k(a,b)},l):k(a,b)}),j()})};b.exports=function(a){return c(this)?this.then(function(b){return g(b,a)}):g(this,a)}},{"./_utils":13,"./isPromise":33}],15:[function(a,b){"use strict";b.exports=function(a){return"function"==typeof a&&this.then(function(b){return a(void 0,b)},a),this}},{}],16:[function(a,b){"use strict";function c(a,b){var c;try{c=this.iterator[a](b)}catch(a){return this.reject(a)}b=c.value,c.done?this.resolve(b):this.toPromise(b).then(this.onFulfill,this.onReject)}function d(a,b,d){this.iterator=a,this.onFulfill=c.bind(this,"next"),this.onReject=c.bind(this,"throw"),this.reject=d,this.resolve=b,this.toPromise=e}var e=a("./_resolve"),f=function(a){return function(){var b=this,c=arguments;return new Promise(function(e,f){return new d(a.apply(b,c),e,f).onFulfill()})}};f.cancelable=function(a){return function(b){var c=this,f=arguments;return b.requested?Promise.reject(b.reason):new Promise(function(g,h){var i=new d(a.apply(c,f),g,h),j=b.promise;j.then(function(){i.toPromise=e}),i.toPromise=function(a){return new Promise(function(b,c){e(a).then(b,c),j.then(c)})},i.onFulfill()})}},b.exports=f},{"./_resolve":10}],17:[function(a,b){"use strict";var c=a("./CancelToken"),d=c.isCancelToken,e=c.source;b.exports=function(a,b,c){function f(){var a=arguments.length;if(0!==a&&d(arguments[0]))return g.apply(this,arguments);var b=e(),c=b.cancel,f=b.token,h=Array(a+1);h[0]=f;for(var j=0;j<a;++j)h[j+1]=arguments[j];var k=g.apply(this,h);return k.cancel=c,k}var g=c===void 0?a:c.value;return void 0===c?f:(c.value=f,c)}},{"./CancelToken":2}],18:[function(a,b){"use strict";var c=a("./_isProgrammerError"),d=function(a,b){if("function"==typeof a)return a===Error||a.prototype instanceof Error?b instanceof a:a(b);if(null!=b&&"object"==typeof a){for(var c in a)if(hasOwnProperty.call(a,c)&&b[c]!==a[c])return!1;return!0}};b.exports=function(){var a,b=this,e=arguments.length;if(0===e||"function"!=typeof(a=arguments[--e]))return this;if(0===e)return this.then(void 0,function(d){return c(d)?b:a(d)});for(var f=Array(e),g=0;g<e;++g)f[g]=arguments[g];return this.then(void 0,function(c){for(var g=0;g<e;++g)if(d(f[g],c))return a(c);return b})}},{"./_isProgrammerError":6}],19:[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}}},{}],20:[function(a,b){"use strict";var c=a("./isPromise");b.exports=function(a){var b=2===arguments.length?arguments[1]:this;return c(b)?b.then(function(b){return new Promise(function(c){setTimeout(c,a,b)})}):new Promise(function(c){setTimeout(c,a,b)})}},{"./isPromise":33}],21:[function(a,b){"use strict";var c=a("./_Resource");b.exports=function a(a){return new c(this,a)}},{"./_Resource":4}],22:[function(a,b){"use strict";b.exports=function(a){var b=this;return this.then(a,a).then(function(){return b})}},{}],23:[function(a,b){"use strict";b.exports=a("./makeAsyncIterator")(a("./_utils").forArray)},{"./_utils":13,"./makeAsyncIterator":34}],24:[function(a,b){"use strict";b.exports=a("./makeAsyncIterator")(a("./_utils").forEach)},{"./_utils":13,"./makeAsyncIterator":34}],25:[function(a,b){"use strict";b.exports=a("./makeAsyncIterator")(a("./_utils").forIn)},{"./_utils":13,"./makeAsyncIterator":34}],26:[function(a,b){"use strict";b.exports=a("./makeAsyncIterator")(a("./_utils").forIterable)},{"./_utils":13,"./makeAsyncIterator":34}],27:[function(a,b){"use strict";b.exports=a("./makeAsyncIterator")(a("./_utils").forOwn)},{"./_utils":13,"./makeAsyncIterator":34}],28:[function(a,b){"use strict";b.exports=function(a){return new Promise(function(b,c){return a(function(a,d){return null==a?b(d):c(a)})})}},{}],29:[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":7,"./cancelable":17}],30:[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":7,"./_utils":13,"./cancelable":17}],31:[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":6}],32:[function(a,b,c){"use strict";c.pAll=c.all=a("./all"),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.pDisposer=c.disposer=a("./disposer"),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.pMap=c.map=a("./map"),c.pPromisify=c.promisify=a("./promisify"),c.pPromisifyAll=c.promisifyAll=a("./promisifyAll"),c.pReflect=c.reflect=a("./reflect"),c.pSettle=c.settle=a("./settle"),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.pUsing=c.using=a("./using"),c.pWrapApply=c.wrapApply=a("./wrapApply"),c.pWrapCall=c.wrapCall=a("./wrapCall")},{"./Cancel":1,"./CancelToken":2,"./TimeoutError":3,"./all":14,"./asCallback":15,"./asyncFn":16,"./cancelable":17,"./catch":18,"./defer":19,"./delay":20,"./disposer":21,"./finally":22,"./forArray":23,"./forEach":24,"./forIn":25,"./forIterable":26,"./forOwn":27,"./fromCallback":28,"./fromEvent":29,"./fromEvents":30,"./ignoreErrors":31,"./isPromise":33,"./makeAsyncIterator":34,"./map":35,"./promisify":37,"./promisifyAll":38,"./reflect":39,"./settle":40,"./some":41,"./suppressUnhandledRejections":42,"./tap":43,"./tapCatch":44,"./timeout":45,"./try":46,"./unpromisify":47,"./using":48,"./wrapApply":49,"./wrapCall":50}],33:[function(a,b){"use strict";b.exports=function(a){return null!=a&&"function"==typeof a.then}},{}],34:[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":8,"./_utils":13}],35:[function(a,b){"use strict";var c=a("./defer"),d=a("./_identity"),e=a("./isPromise"),f=a("./_utils"),g=f.applyThen,h=f.forEach,i=function a(b,f){if(void 0===f&&(f=d),e(b))return b.then(function(b){return a(b,f)});var j,k=1,l=[],m=c(),n=m.promise,o=m.reject,p=m.resolve,q=function(){0==--k&&(void 0===j?p(l):o(j.error))},r=function(a){void 0===j&&(j={error:a}),q()},s=function a(b){var c=b[0];return e(c)?c.then(function(c){return b[0]=c,a(b)}):void g(f,b,function(a){l[b[3]]=a,q()},r)},t=0;return h(b,function(a,b,c){++k,s([a,b,c,t++])}),q(),n};b.exports=function(a){return i(this,a)}},{"./_identity":5,"./_utils":13,"./defer":19,"./isPromise":33}],36:[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},{}],37:[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 a?g(a):f(b)},a.apply(b===void 0?c:b,e)})},a.name,0!==a.length&&a.length-1)}},{"./_setFunctionNameAndLength":11}],38:[function(a,b){"use strict";var c=a("./promisify"),d=a("./_utils"),e=d.endsWith,f=d.forIn,g=function(a,b){return!(e(b,"Sync")||e(b,"Async"))&&b};b.exports=function(a,b){var d=void 0===b?{}:b,e=d.mapper,h=void 0===e?g:e,i=d.target,j=void 0===i?{}:i,k=d.context,l=void 0===k?a:k;return f(a,function(b,d){var e;"function"==typeof b&&(e=h(b,d,a))&&(j[e]=c(b,l))}),j}},{"./_utils":13,"./promisify":37}],39:[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)}},{}],40:[function(a,b){"use strict";var c=a("./all"),d=a("./reflect"),e=a("./_resolve");b.exports=function(){return c.call(this,function(a){var b;return(b=e(a),d).call(b)})}},{"./_resolve":10,"./all":14,"./reflect":39}],41:[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":10,"./_utils":13}],42:[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":8}],43:[function(a,b){"use strict";b.exports=function(a,b){var c=this;return this.then(a,b).then(function(){return c})}},{}],44:[function(a,b){"use strict";b.exports=function(a){var b=this;return this.then(void 0,a).then(function(){return b})}},{}],45:[function(a,b){"use strict";var c=a("./TimeoutError");b.exports=function(a,b){var d=this;return void 0===b&&(b=new c),0===a?this: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":3}],46:[function(a,b){"use strict";var c=a("./_resolve");b.exports=function(a){try{return c(a())}catch(a){return Promise.reject(a)}}},{"./_resolve":10}],47:[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":11}],48:[function(a,b){"use strict";var c=a("./_once"),d=a("./_Resource"),e=a("./wrapApply"),f=a("./wrapCall"),g=a("./_utils"),h=g.forArray,j=g.isArray;b.exports=function(){var a=this,b=arguments.length-1;if(1>b)throw new TypeError("using expects at least 2 arguments");var g=arguments[b],k=arguments[0],l=1<b||!j(k);if(l){k=Array(b);for(var m=0;m<b;++m)k[m]=arguments[m]}else b=k.length;var n=c(function(a,c){var e=b,g=function(){0==--e&&a(c)},i=function(a){setTimeout(function(){throw a},0)};h(k,function(a){var b;null!=a&&"function"==typeof(b=a.d)?(a.p.then(function(a){return f(b,a).then(g,i)},g),a.p=a.d=void 0):--e})});return new Promise(function(c,i){var j=Array(b),m=b,o=function(a){o=r,s=function(){return n(i,a)},r()},q=function(a){return o(a)},r=function(){0==--m&&s()},s=function(){return(l?e:f)(g,j,a).then(function(a){return n(c,a)},function(a){return n(i,a)})};h(k,function(a,b){var c;if(!(a instanceof d))c=Promise.resolve(a);else if(c=a.p,void 0===c)return q(new TypeError("resource has already been disposed of"));c.then(function(a){j[b]=a,r()},q)})})}},{"./_Resource":4,"./_once":9,"./_utils":13,"./wrapApply":49,"./wrapCall":50}],49:[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":10}],50:[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":10}]},{},[32])(32)});
(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._handlers;if(void 0!==d){this._handlers=void 0;for(var e=h(),f=e.promise,g=e.resolve,l=0,m=function(){if(0==--l)return g()},o=0,p=d.length;o<p;++o)try{var n=d[o](b);k(n)&&(++l,n.then(m,m))}catch(a){}if(0!==l)return f}}}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 p(o));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("./_symbols"),m=l.$$toStringTag,n="CancelToken",o={},p=function(){function a(a){this._handlers=void 0,this._promise=void 0,this._reason=void 0,this._resolve=void 0,a!==o&&a(e.bind(this))}a.isCancelToken=function(a){return null!=a&&a[m]===n},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},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:m,get:function(){return n}}]),a}();e.call(p.canceled=new p(o)),p.none=new p(o),b.exports=p},{"./Cancel":1,"./_symbols":13,"./defer":20,"./isPromise":34}],3:[function(a,b){"use strict";function c(a,b){a.prototype=Object.create(b.prototype),a.prototype.constructor=a,a.__proto__=b}var d=a("make-error"),e=d.BaseError;b.exports=function(a){function b(){return a.call(this,"operation timed out")||this}return c(b,a),b}(e)},{"make-error":37}],4:[function(a,b){"use strict";b.exports=function(a,b){this.d=b,this.p=a}},{}],5:[function(a,b){"use strict";b.exports=function(a){return a}},{}],6:[function(a,b){"use strict";b.exports=function(a){return a instanceof ReferenceError||a instanceof SyntaxError||a instanceof TypeError}},{}],7:[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.event=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":9,"./_once":10}],8:[function(a,b){"use strict";var c=a("./_isProgrammerError");b.exports=function a(b,d){if(b===void 0)return!c(d);if("function"==typeof b)return b===Error||b.prototype instanceof Error?d instanceof b:b(d);if(Array.isArray(b)){for(var e=b.length,f=0;f<e;++f)if(a(b[f],d))return!0;return!1}if(null!=d&&"object"==typeof b){for(var g in b)if(hasOwnProperty.call(b,g)&&d[g]!==b[g])return!1;return!0}}},{"./_isProgrammerError":6}],9:[function(a,b){"use strict";b.exports=Function.prototype},{}],10:[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}}},{}],11:[function(a,b){"use strict";var c=a("./isPromise");b.exports=function(a){return c(a)?a:Promise.resolve(a)}},{"./isPromise":34}],12:[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":5}],13:[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")},{}],14:[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;c.applyThen=function(a,b,c,e){var f;try{if(f=a.apply(void 0,b),d(f))return void f.then(c,e)}catch(a){return void e(a)}c(f)};var 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":13,"./isPromise":34}],15:[function(a,b){"use strict";var c=a("./isPromise"),d=a("./_utils"),e=d.forEach,f=d.mapAuto,g=function(a,b){return new Promise(function(d,g){var h=f(a,b),i=1,j=function(){if(0==--i){var a=h;h=void 0,d(a)}},k=function(a,b){h&&(h[b]=a,j())},l=function(a){h&&(h=void 0,g(a))};e(b===void 0?a:h,function(a,b){++i,c(a)?a.then(function(a){return k(a,b)},l):k(a,b)}),j()})};b.exports=function(a){return c(this)?this.then(function(b){return g(b,a)}):g(this,a)}},{"./_utils":14,"./isPromise":34}],16:[function(a,b){"use strict";b.exports=function(a){return"function"==typeof a&&this.then(function(b){return a(void 0,b)},a),this}},{}],17:[function(a,b){"use strict";function c(a,b){var c;try{c=this.iterator[a](b)}catch(a){return this.reject(a)}b=c.value,c.done?this.resolve(b):this.toPromise(b).then(this.onFulfill,this.onReject)}function d(a,b,d){this.iterator=a,this.onFulfill=c.bind(this,"next"),this.onReject=c.bind(this,"throw"),this.reject=d,this.resolve=b,this.toPromise=e}var e=a("./_resolve"),f=function(a){return function(){var b=this,c=arguments;return new Promise(function(e,f){return new d(a.apply(b,c),e,f).onFulfill()})}};f.cancelable=function(a){return function(b){var c=this,f=arguments;return b.requested?Promise.reject(b.reason):new Promise(function(g,h){var i=new d(a.apply(c,f),g,h),j=b.promise;j.then(function(){i.toPromise=e}),i.toPromise=function(a){return new Promise(function(b,c){e(a).then(b,c),j.then(c)})},i.onFulfill()})}},b.exports=f},{"./_resolve":11}],18:[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":12}],19:[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":8}],20:[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}}},{}],21:[function(a,b){"use strict";var c=a("./isPromise");b.exports=function(a){var b=2===arguments.length?arguments[1]:this;return c(b)?b.then(function(b){return new Promise(function(c){setTimeout(c,a,b)})}):new Promise(function(c){setTimeout(c,a,b)})}},{"./isPromise":34}],22:[function(a,b){"use strict";var c=a("./_Resource");b.exports=function a(a){return new c(this,a)}},{"./_Resource":4}],23:[function(a,b){"use strict";b.exports=function(a){var b=this;return this.then(a,a).then(function(){return b})}},{}],24:[function(a,b){"use strict";b.exports=a("./makeAsyncIterator")(a("./_utils").forArray)},{"./_utils":14,"./makeAsyncIterator":35}],25:[function(a,b){"use strict";b.exports=a("./makeAsyncIterator")(a("./_utils").forEach)},{"./_utils":14,"./makeAsyncIterator":35}],26:[function(a,b){"use strict";b.exports=a("./makeAsyncIterator")(a("./_utils").forIn)},{"./_utils":14,"./makeAsyncIterator":35}],27:[function(a,b){"use strict";b.exports=a("./makeAsyncIterator")(a("./_utils").forIterable)},{"./_utils":14,"./makeAsyncIterator":35}],28:[function(a,b){"use strict";b.exports=a("./makeAsyncIterator")(a("./_utils").forOwn)},{"./_utils":14,"./makeAsyncIterator":35}],29:[function(a,b){"use strict";b.exports=function(a){return new Promise(function(b,c){return a(function(a,d){return null==a?b(d):c(a)})})}},{}],30:[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":7,"./cancelable":18}],31:[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":7,"./_utils":14,"./cancelable":18}],32:[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":6}],33:[function(a,b,c){"use strict";c.pAll=c.all=a("./all"),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.pDisposer=c.disposer=a("./disposer"),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.pMap=c.map=a("./map"),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.pSettle=c.settle=a("./settle"),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.pUsing=c.using=a("./using"),c.pWrapApply=c.wrapApply=a("./wrapApply"),c.pWrapCall=c.wrapCall=a("./wrapCall")},{"./Cancel":1,"./CancelToken":2,"./TimeoutError":3,"./all":15,"./asCallback":16,"./asyncFn":17,"./cancelable":18,"./catch":19,"./defer":20,"./delay":21,"./disposer":22,"./finally":23,"./forArray":24,"./forEach":25,"./forIn":26,"./forIterable":27,"./forOwn":28,"./fromCallback":29,"./fromEvent":30,"./fromEvents":31,"./ignoreErrors":32,"./isPromise":34,"./makeAsyncIterator":35,"./map":36,"./pipe":38,"./promisify":39,"./promisifyAll":40,"./reflect":41,"./retry":42,"./settle":43,"./some":44,"./suppressUnhandledRejections":45,"./tap":46,"./tapCatch":47,"./timeout":48,"./try":49,"./unpromisify":50,"./using":51,"./wrapApply":52,"./wrapCall":53}],34:[function(a,b){"use strict";b.exports=function(a){return null!=a&&"function"==typeof a.then}},{}],35:[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":9,"./_utils":14}],36:[function(a,b){"use strict";var c=a("./defer"),d=a("./_identity"),e=a("./isPromise"),f=a("./_utils"),g=f.applyThen,h=f.forEach,i=function a(b,f){if(void 0===f&&(f=d),e(b))return b.then(function(b){return a(b,f)});var j,k=1,l=[],m=c(),n=m.promise,o=m.reject,p=m.resolve,q=function(){0==--k&&(void 0===j?p(l):o(j.error))},r=function(a){void 0===j&&(j={error:a}),q()},s=function a(b){var c=b[0];return e(c)?c.then(function(c){return b[0]=c,a(b)}):void g(f,b,function(a){l[b[3]]=a,q()},r)},t=0;return h(b,function(a,b,c){++k,s([a,b,c,t++])}),q(),n};b.exports=function(a){return i(this,a)}},{"./_identity":5,"./_utils":14,"./defer":20,"./isPromise":34}],37:[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},{}],38:[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(b){return a.reduce(e,Promise.resolve(b))}}},{}],39:[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?f(b):g(a)},a.apply(b===void 0?c:b,e)})},a.name,a.length-1)}},{"./_setFunctionNameAndLength":12}],40:[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":14,"./promisify":39}],41:[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)}},{}],42:[function(a,b){"use strict";function c(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function d(a){return function(){var b=this,d=arguments;return new Promise(function(e,f){function g(a){c(i,e,f,g,h,"next",a)}function h(a){c(i,e,f,g,h,"throw",a)}var i=a.apply(b,d);g(void 0)})}}function e(a){throw this.error=a,this}var f=a("./_matchError"),g=a("./_noop"),h=a("./delay");b.exports=function(){var a=d(regeneratorRuntime.mark(function a(b,c){var d,i,j,k,l,m,n,o,p,q;return regeneratorRuntime.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:d=void 0===c?{}:c,i=d.delay,j=void 0===i?1e3:i,k=d.onRetry,l=void 0===k?g:k,m=d.tries,n=void 0===m?10:m,o=d.when,p={error:void 0},q=e.bind(p),o=f.bind(void 0,o);case 4:return a.prev=5,a.next=8,b(q);case 8:return a.abrupt("return",a.sent);case 11:if(a.prev=11,a.t0=a["catch"](5),a.t0!==p){a.next=15;break}throw p.error;case 15:if(0!=--n&&o(a.t0)){a.next=17;break}throw a.t0;case 17:return a.next=19,l(a.t0);case 19:return a.next=21,h(j);case 21:a.next=4;break;case 23:case"end":return a.stop();}},a,this,[[5,11]])}));return function(){return a.apply(this,arguments)}}()},{"./_matchError":8,"./_noop":9,"./delay":21}],43:[function(a,b){"use strict";var c=a("./all"),d=a("./reflect"),e=a("./_resolve");b.exports=function(){return c.call(this,function(a){var b;return(b=e(a),d).call(b)})}},{"./_resolve":11,"./all":15,"./reflect":41}],44:[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":11,"./_utils":14}],45:[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":9}],46:[function(a,b){"use strict";b.exports=function(a,b){var c=this;return this.then(a,b).then(function(){return c})}},{}],47:[function(a,b){"use strict";b.exports=function(a){var b=this;return this.then(void 0,a).then(function(){return b})}},{}],48:[function(a,b){"use strict";var c=a("./TimeoutError");b.exports=function(a,b){var d=this;return void 0===b&&(b=new c),0===a?this: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":3}],49:[function(a,b){"use strict";var c=a("./_resolve");b.exports=function(a){try{return c(a())}catch(a){return Promise.reject(a)}}},{"./_resolve":11}],50:[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":12}],51:[function(a,b){"use strict";var c=a("./_once"),d=a("./_Resource"),e=a("./wrapApply"),f=a("./wrapCall"),g=a("./_utils"),h=g.forArray;b.exports=function(){var a=this,b=arguments.length-1;if(1>b)throw new TypeError("using expects at least 2 arguments");var g,i=arguments[b],j=1<b||!Array.isArray(g=arguments[0]);j?g=Array.prototype.slice.call(arguments,0,b):b=g.length;var k=c(function(a,c){var e=b,i=function(){0==--e&&a(c)},j=function(a){setTimeout(function(){throw a},0)};h(g,function(a){var b;null!=a&&"function"==typeof(b=a.d)?(a.p.then(function(a){return f(b,a).then(i,j)},i),a.p=a.d=void 0):--e})});return new Promise(function(c,l){var m=Array(b),n=b,o=function(a){o=r,s=function(){return k(l,a)},r()},q=function(a){return o(a)},r=function(){0==--n&&s()},s=function(){return(j?e:f)(i,m,a).then(function(a){return k(c,a)},function(a){return k(l,a)})};h(g,function(a,b){var c;if(!(a instanceof d))c=Promise.resolve(a);else if(c=a.p,void 0===c)return q(new TypeError("resource has already been disposed of"));c.then(function(a){m[b]=a,r()},q)})})}},{"./_Resource":4,"./_once":10,"./_utils":14,"./wrapApply":52,"./wrapCall":53}],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":11}],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":11}]},{},[33])(33)});
"use strict";
var setFunctionNameAndLength = require('./_setFunctionNameAndLength');
var setFunctionNameAndLength = require("./_setFunctionNameAndLength");

@@ -11,4 +11,4 @@ module.exports = function unpromisify() {

if (n < 0 || typeof (cb = arguments[n]) !== 'function') {
throw new Error('missing callback');
if (n < 0 || typeof (cb = arguments[n]) !== "function") {
throw new Error("missing callback");
}

@@ -15,0 +15,0 @@

"use strict";
var once = require('./_once');
var once = require("./_once");
var Resource = require('./_Resource');
var Resource = require("./_Resource");
var wrapApply = require('./wrapApply');
var wrapApply = require("./wrapApply");
var wrapCall = require('./wrapCall');
var wrapCall = require("./wrapCall");
var _require = require('./_utils'),
forArray = _require.forArray,
isArray = _require.isArray;
var _require = require("./_utils"),
forArray = _require.forArray;

@@ -21,15 +20,11 @@ module.exports = function using() {

if (nResources < 1) {
throw new TypeError('using expects at least 2 arguments');
throw new TypeError("using expects at least 2 arguments");
}
var handler = arguments[nResources];
var resources = arguments[0];
var spread = nResources > 1 || !isArray(resources);
var resources;
var spread = nResources > 1 || !Array.isArray(resources = arguments[0]);
if (spread) {
resources = new Array(nResources);
for (var i = 0; i < nResources; ++i) {
resources[i] = arguments[i];
}
resources = Array.prototype.slice.call(arguments, 0, nResources);
} else {

@@ -57,3 +52,3 @@ nResources = resources.length;

if (resource != null && typeof (d = resource.d) === 'function') {
if (resource != null && typeof (d = resource.d) === "function") {
resource.p.then(function (value) {

@@ -107,3 +102,3 @@ return wrapCall(d, value).then(onSettle, onFailure);

if (p === undefined) {
return onProviderFailure(new TypeError('resource has already been disposed of'));
return onProviderFailure(new TypeError("resource has already been disposed of"));
}

@@ -110,0 +105,0 @@ } else {

"use strict";
var resolve = require('./_resolve');
var resolve = require("./_resolve");

@@ -5,0 +5,0 @@ var wrapApply = function wrapApply(fn, args, thisArg) {

"use strict";
var resolve = require('./_resolve');
var resolve = require("./_resolve");

@@ -5,0 +5,0 @@ var wrapCall = function wrapCall(fn, arg, thisArg) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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