-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Require Node.js 12.20 and move to ESM
- Loading branch information
1 parent
3c8b743
commit df9b57b
Showing
8 changed files
with
72 additions
and
86 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,34 @@ | ||
import PCancelable = require('p-cancelable'); | ||
import { | ||
Options as PSomeOptions, | ||
AggregateError as PSomeAggregateError | ||
} from 'p-some'; | ||
|
||
declare namespace pAny { | ||
type Value<ValueType> = ValueType | PromiseLike<ValueType>; | ||
type Options<ValueType> = Omit<PSomeOptions<ValueType>, 'count'>; | ||
type CancelablePromise<ValueType> = PCancelable<ValueType>; | ||
type AggregateError = PSomeAggregateError; | ||
} | ||
|
||
declare const pAny: { | ||
/** | ||
Wait for any promise to be fulfilled. | ||
@param input - An `Iterable` collection of promises/values to wait for. | ||
@returns A [cancelable `Promise`](https://github.com/sindresorhus/p-cancelable) that is fulfilled when any promise from `input` is fulfilled. If all the input promises reject, it will reject with an [`AggregateError`](https://github.com/sindresorhus/aggregate-error) error. | ||
@example | ||
``` | ||
import got = require('got'); | ||
import pAny = require('p-any'); | ||
(async () => { | ||
const first = await pAny([ | ||
got.head('https://github.com').then(() => 'github'), | ||
got.head('https://google.com').then(() => 'google'), | ||
got.head('https://twitter.com').then(() => 'twitter'), | ||
]); | ||
console.log(first); | ||
//=> 'google' | ||
})(); | ||
``` | ||
*/ | ||
<ValueType>( | ||
input: Iterable<pAny.Value<ValueType>>, | ||
options?: pAny.Options<ValueType> | ||
): pAny.CancelablePromise<ValueType>; | ||
|
||
AggregateError: typeof PSomeAggregateError; | ||
}; | ||
|
||
export = pAny; | ||
import PCancelable from 'p-cancelable'; | ||
import {Options as PSomeOptions} from 'p-some'; | ||
|
||
export type Value<ValueType> = ValueType | PromiseLike<ValueType>; | ||
export type Options<ValueType> = Omit<PSomeOptions<ValueType>, 'count'>; // eslint-disable-line @typescript-eslint/ban-types | ||
export type CancelablePromise<ValueType> = PCancelable<ValueType>; | ||
|
||
/** | ||
Wait for any promise to be fulfilled. | ||
@param input - An `Iterable` collection of promises/values to wait for. | ||
@returns A [cancelable `Promise`](https://github.com/sindresorhus/p-cancelable) that is fulfilled when any promise from `input` is fulfilled. If all the input promises reject, it will reject with an [`AggregateError`](https://github.com/sindresorhus/aggregate-error) error. | ||
@example | ||
``` | ||
import pAny from 'p-any'; | ||
import got from 'got'; | ||
const first = await pAny([ | ||
got.head('https://github.com').then(() => 'github'), | ||
got.head('https://google.com').then(() => 'google'), | ||
got.head('https://twitter.com').then(() => 'twitter'), | ||
]); | ||
console.log(first); | ||
//=> 'google' | ||
``` | ||
*/ | ||
export default function pAny<ValueType>( | ||
input: Iterable<Value<ValueType>>, | ||
options?: Options<ValueType> | ||
): CancelablePromise<ValueType>; | ||
|
||
export {AggregateError} from 'p-some'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,8 +10,10 @@ | |
"email": "[email protected]", | ||
"url": "https://sindresorhus.com" | ||
}, | ||
"type": "module", | ||
"exports": "./index.js", | ||
"engines": { | ||
"node": ">=10" | ||
"node": ">=12.20" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava && tsd" | ||
|
@@ -39,13 +41,13 @@ | |
"bluebird" | ||
], | ||
"dependencies": { | ||
"p-cancelable": "^2.0.0", | ||
"p-some": "^5.0.0" | ||
"p-cancelable": "^3.0.0", | ||
"p-some": "^6.0.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "^1.4.1", | ||
"delay": "^4.1.0", | ||
"tsd": "^0.11.0", | ||
"xo": "^0.26.1" | ||
"ava": "^3.15.0", | ||
"delay": "^5.0.0", | ||
"tsd": "^0.16.0", | ||
"xo": "^0.40.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters