diff options
Diffstat (limited to 'deps/npm/node_modules/libnpmconfig')
8 files changed, 123 insertions, 33 deletions
diff --git a/deps/npm/node_modules/libnpmconfig/node_modules/p-limit/index.d.ts b/deps/npm/node_modules/libnpmconfig/node_modules/p-limit/index.d.ts new file mode 100644 index 0000000000..02988aaf89 --- /dev/null +++ b/deps/npm/node_modules/libnpmconfig/node_modules/p-limit/index.d.ts @@ -0,0 +1,29 @@ +export interface Limit { + /** + * @param fn - Promise-returning/async function. + * @param arguments - Any arguments to pass through to `fn`. Support for passing arguments on to the `fn` is provided in order to be able to avoid creating unnecessary closures. You probably don't need this optimization unless you're pushing a lot of functions. + * @returns The promise returned by calling `fn(...arguments)`. + */ + <Arguments extends unknown[], ReturnType>( + fn: (...arguments: Arguments) => PromiseLike<ReturnType> | ReturnType, + ...arguments: Arguments + ): Promise<ReturnType>; + + /** + * The number of promises that are currently running. + */ + readonly activeCount: number; + + /** + * The number of promises that are waiting to run (i.e. their internal `fn` was not called yet). + */ + readonly pendingCount: number; +} + +/** + * Run multiple promise-returning & async functions with limited concurrency. + * + * @param concurrency - Concurrency limit. Minimum: `1`. + * @returns A `limit` function. + */ +export default function pLimit(concurrency: number): Limit; diff --git a/deps/npm/node_modules/libnpmconfig/node_modules/p-limit/index.js b/deps/npm/node_modules/libnpmconfig/node_modules/p-limit/index.js index 86decabbc0..d22fbe8a49 100644 --- a/deps/npm/node_modules/libnpmconfig/node_modules/p-limit/index.js +++ b/deps/npm/node_modules/libnpmconfig/node_modules/p-limit/index.js @@ -1,7 +1,7 @@ 'use strict'; const pTry = require('p-try'); -module.exports = concurrency => { +const pLimit = concurrency => { if (concurrency < 1) { throw new TypeError('Expected `concurrency` to be a number from 1 and up'); } @@ -47,3 +47,6 @@ module.exports = concurrency => { return generator; }; + +module.exports = pLimit; +module.exports.default = pLimit; diff --git a/deps/npm/node_modules/libnpmconfig/node_modules/p-limit/package.json b/deps/npm/node_modules/libnpmconfig/node_modules/p-limit/package.json index 233b3f13d7..9c9c7d9ffc 100644 --- a/deps/npm/node_modules/libnpmconfig/node_modules/p-limit/package.json +++ b/deps/npm/node_modules/libnpmconfig/node_modules/p-limit/package.json @@ -1,8 +1,8 @@ { "_from": "p-limit@^2.0.0", - "_id": "p-limit@2.1.0", + "_id": "p-limit@2.2.0", "_inBundle": false, - "_integrity": "sha512-NhURkNcrVB+8hNfLuysU8enY5xn2KXphsHBaC2YmRNTZRc7RWusw6apSpdEj3jo4CMb6W9nrF6tTnsJsJeyu6g==", + "_integrity": "sha512-pZbTJpoUsCzV48Mc9Nh51VbwO0X9cuPFE8gYwx9BTCt9SF8/b7Zljd2fVgOxhIF/HDTKgpVzs+GPhyKfjLLFRQ==", "_location": "/libnpmconfig/p-limit", "_phantomChildren": {}, "_requested": { @@ -18,10 +18,10 @@ "_requiredBy": [ "/libnpmconfig/p-locate" ], - "_resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.1.0.tgz", - "_shasum": "1d5a0d20fb12707c758a655f6bbc4386b5930d68", + "_resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.0.tgz", + "_shasum": "417c9941e6027a9abcba5092dd2904e255b5fbc2", "_spec": "p-limit@^2.0.0", - "_where": "/Users/zkat/Documents/code/work/npm/node_modules/libnpmconfig/node_modules/p-locate", + "_where": "/Users/isaacs/dev/npm/cli/node_modules/libnpmconfig/node_modules/p-locate", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", @@ -37,18 +37,20 @@ "deprecated": false, "description": "Run multiple promise-returning & async functions with limited concurrency", "devDependencies": { - "ava": "^1.0.1", + "ava": "^1.2.1", "delay": "^4.1.0", "in-range": "^1.0.0", "random-int": "^1.0.0", "time-span": "^2.0.0", - "xo": "^0.23.0" + "tsd-check": "^0.3.0", + "xo": "^0.24.0" }, "engines": { "node": ">=6" }, "files": [ - "index.js" + "index.js", + "index.d.ts" ], "homepage": "https://github.com/sindresorhus/p-limit#readme", "keywords": [ @@ -75,7 +77,7 @@ "url": "git+https://github.com/sindresorhus/p-limit.git" }, "scripts": { - "test": "xo && ava" + "test": "xo && ava && tsd-check" }, - "version": "2.1.0" + "version": "2.2.0" } diff --git a/deps/npm/node_modules/libnpmconfig/node_modules/p-limit/readme.md b/deps/npm/node_modules/libnpmconfig/node_modules/p-limit/readme.md index 92a6dbf774..b87f3e0c9c 100644 --- a/deps/npm/node_modules/libnpmconfig/node_modules/p-limit/readme.md +++ b/deps/npm/node_modules/libnpmconfig/node_modules/p-limit/readme.md @@ -54,7 +54,7 @@ Type: `Function` Promise-returning/async function. -#### ...args +#### args Any arguments to pass through to `fn`. diff --git a/deps/npm/node_modules/libnpmconfig/node_modules/p-try/index.d.ts b/deps/npm/node_modules/libnpmconfig/node_modules/p-try/index.d.ts new file mode 100644 index 0000000000..2a7319ec2a --- /dev/null +++ b/deps/npm/node_modules/libnpmconfig/node_modules/p-try/index.d.ts @@ -0,0 +1,39 @@ +declare const pTry: { + /** + Start a promise chain. + + @param fn - The function to run to start the promise chain. + @param arguments - Arguments to pass to `fn`. + @returns The value of calling `fn(...arguments)`. If the function throws an error, the returned `Promise` will be rejected with that error. + + @example + ``` + import pTry = require('p-try'); + + (async () => { + try { + const value = await pTry(() => { + return synchronousFunctionThatMightThrow(); + }); + console.log(value); + } catch (error) { + console.error(error); + } + })(); + ``` + */ + <ValueType, ArgumentsType extends unknown[]>( + fn: (...arguments: ArgumentsType) => PromiseLike<ValueType> | ValueType, + ...arguments: ArgumentsType + ): Promise<ValueType>; + + // TODO: remove this in the next major version, refactor the whole definition to: + // declare function pTry<ValueType, ArgumentsType extends unknown[]>( + // fn: (...arguments: ArgumentsType) => PromiseLike<ValueType> | ValueType, + // ...arguments: ArgumentsType + // ): Promise<ValueType>; + // export = pTry; + default: typeof pTry; +}; + +export = pTry; diff --git a/deps/npm/node_modules/libnpmconfig/node_modules/p-try/index.js b/deps/npm/node_modules/libnpmconfig/node_modules/p-try/index.js index 2d26268d47..db858da292 100644 --- a/deps/npm/node_modules/libnpmconfig/node_modules/p-try/index.js +++ b/deps/npm/node_modules/libnpmconfig/node_modules/p-try/index.js @@ -1,5 +1,9 @@ 'use strict'; -module.exports = (callback, ...args) => new Promise(resolve => { - resolve(callback(...args)); +const pTry = (fn, ...arguments_) => new Promise(resolve => { + resolve(fn(...arguments_)); }); + +module.exports = pTry; +// TODO: remove this in the next major version +module.exports.default = pTry; diff --git a/deps/npm/node_modules/libnpmconfig/node_modules/p-try/package.json b/deps/npm/node_modules/libnpmconfig/node_modules/p-try/package.json index d8aef830b5..af14d60c36 100644 --- a/deps/npm/node_modules/libnpmconfig/node_modules/p-try/package.json +++ b/deps/npm/node_modules/libnpmconfig/node_modules/p-try/package.json @@ -1,8 +1,8 @@ { "_from": "p-try@^2.0.0", - "_id": "p-try@2.0.0", + "_id": "p-try@2.2.0", "_inBundle": false, - "_integrity": "sha512-hMp0onDKIajHfIkdRk3P4CdCmErkYAxxDtP3Wx/4nZ3aGlau2VKh3mZpcuFkH27WQkL/3WBCPOktzA9ZOAnMQQ==", + "_integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", "_location": "/libnpmconfig/p-try", "_phantomChildren": {}, "_requested": { @@ -18,10 +18,10 @@ "_requiredBy": [ "/libnpmconfig/p-limit" ], - "_resolved": "https://registry.npmjs.org/p-try/-/p-try-2.0.0.tgz", - "_shasum": "85080bb87c64688fa47996fe8f7dfbe8211760b1", + "_resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "_shasum": "cb2868540e313d61de58fafbe35ce9004d5540e6", "_spec": "p-try@^2.0.0", - "_where": "/Users/zkat/Documents/code/work/npm/node_modules/libnpmconfig/node_modules/p-limit", + "_where": "/Users/isaacs/dev/npm/cli/node_modules/libnpmconfig/node_modules/p-limit", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", @@ -34,14 +34,16 @@ "deprecated": false, "description": "`Start a promise chain", "devDependencies": { - "ava": "*", - "xo": "*" + "ava": "^1.4.1", + "tsd": "^0.7.1", + "xo": "^0.24.0" }, "engines": { "node": ">=6" }, "files": [ - "index.js" + "index.js", + "index.d.ts" ], "homepage": "https://github.com/sindresorhus/p-try#readme", "keywords": [ @@ -66,7 +68,7 @@ "url": "git+https://github.com/sindresorhus/p-try.git" }, "scripts": { - "test": "xo && ava" + "test": "xo && ava && tsd" }, - "version": "2.0.0" + "version": "2.2.0" } diff --git a/deps/npm/node_modules/libnpmconfig/node_modules/p-try/readme.md b/deps/npm/node_modules/libnpmconfig/node_modules/p-try/readme.md index 58acb759aa..4d7bd64dfc 100644 --- a/deps/npm/node_modules/libnpmconfig/node_modules/p-try/readme.md +++ b/deps/npm/node_modules/libnpmconfig/node_modules/p-try/readme.md @@ -17,24 +17,35 @@ $ npm install p-try ```js const pTry = require('p-try'); -pTry(() => { - return synchronousFunctionThatMightThrow(); -}).then(value => { - console.log(value); -}).catch(error => { - console.error(error); -}); +(async () => { + try { + const value = await pTry(() => { + return synchronousFunctionThatMightThrow(); + }); + console.log(value); + } catch (error) { + console.error(error); + } +})(); ``` ## API -### pTry(fn, ...args) +### pTry(fn, ...arguments) -Returns a `Promise` resolved with the value of calling `fn(...args)`. If the function throws an error, the returned `Promise` will be rejected with that error. +Returns a `Promise` resolved with the value of calling `fn(...arguments)`. If the function throws an error, the returned `Promise` will be rejected with that error. Support for passing arguments on to the `fn` is provided in order to be able to avoid creating unnecessary closures. You probably don't need this optimization unless you're pushing a *lot* of functions. +#### fn + +The function to run to start the promise chain. + +#### arguments + +Arguments to pass to `fn`. + ## Related |