Skip to content

Commit

Permalink
Improve type definition for combinators (any, first, some) (#334)
Browse files Browse the repository at this point in the history
  • Loading branch information
defaultpage authored Jan 10, 2021
1 parent 73f6e71 commit efca2b3
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions lib/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,11 @@ function adapt($promise): Promise
* This function is the same as some() with the notable exception that it will never fail even
* if all promises in the array resolve unsuccessfully.
*
* @param Promise[]|ReactPromise[] $promises
* @template TValue
*
* @return Promise
* @param Promise<TValue>[]|ReactPromise[] $promises
*
* @return Promise<array{0: \Throwable[], 1: TValue[]}>
*
* @throws \Error If a non-Promise is in the array.
*/
Expand Down Expand Up @@ -423,9 +425,11 @@ function all(array $promises): Promise
/**
* Returns a promise that succeeds when the first promise succeeds, and fails only if all promises fail.
*
* @param Promise[]|ReactPromise[] $promises Array of only promises.
* @template TValue
*
* @return Promise
* @param Promise<TValue>[]|ReactPromise[] $promises Array of only promises.
*
* @return Promise<TValue>
*
* @throws \Error If the array is empty or a non-Promise is in the array.
*/
Expand Down Expand Up @@ -475,12 +479,14 @@ function first(array $promises): Promise
* Resolves with a two-item array delineating successful and failed Promise results.
*
* The returned promise will only fail if the given number of required promises fail.
*
* @template TValue
*
* @param Promise[]|ReactPromise[] $promises Array of only promises.
* @param int $required Number of promises that must succeed for the
* @param Promise<TValue>[]|ReactPromise[] $promises Array of only promises.
* @param int $required Number of promises that must succeed for the
* returned promise to succeed.
*
* @return Promise
* @return Promise<array{0: \Throwable[], 1: TValue[]}>
*
* @throws \Error If a non-Promise is in the array.
*/
Expand Down

0 comments on commit efca2b3

Please sign in to comment.