UNPKG

2.29 kBTypeScriptView Raw
1/*! *****************************************************************************
2Copyright (c) Microsoft Corporation. All rights reserved.
3Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4this file except in compliance with the License. You may obtain a copy of the
5License at http://www.apache.org/licenses/LICENSE-2.0
6
7THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
9WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
10MERCHANTABLITY OR NON-INFRINGEMENT.
11
12See the Apache Version 2.0 License for specific language governing permissions
13and limitations under the License.
14***************************************************************************** */
15
16
17
18/// <reference no-default-lib="true"/>
19
20
21interface AggregateError extends Error {
22 errors: any[]
23}
24
25interface AggregateErrorConstructor {
26 new(errors: Iterable<any>, message?: string): AggregateError;
27 (errors: Iterable<any>, message?: string): AggregateError;
28 readonly prototype: AggregateError;
29}
30
31declare var AggregateError: AggregateErrorConstructor;
32
33/**
34 * Represents the completion of an asynchronous operation
35 */
36interface PromiseConstructor {
37 /**
38 * The any function returns a promise that is fulfilled by the first given promise to be fulfilled, or rejected with an AggregateError containing an array of rejection reasons if all of the given promises are rejected. It resolves all elements of the passed iterable to promises as it runs this algorithm.
39 * @param values An array or iterable of Promises.
40 * @returns A new Promise.
41 */
42 any<T extends readonly unknown[] | []>(values: T): Promise<Awaited<T[number]>>;
43
44 /**
45 * The any function returns a promise that is fulfilled by the first given promise to be fulfilled, or rejected with an AggregateError containing an array of rejection reasons if all of the given promises are rejected. It resolves all elements of the passed iterable to promises as it runs this algorithm.
46 * @param values An array or iterable of Promises.
47 * @returns A new Promise.
48 */
49 any<T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>>
50}