mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-30 11:24:49 -05:00
add Array.fromAsync to esnext (#57748)
Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
This commit is contained in:
@@ -233,6 +233,7 @@ const libEntries: [string, string][] = [
|
||||
["esnext.weakref", "lib.es2021.weakref.d.ts"],
|
||||
["esnext.decorators", "lib.esnext.decorators.d.ts"],
|
||||
["esnext.object", "lib.esnext.object.d.ts"],
|
||||
["esnext.array", "lib.esnext.array.d.ts"],
|
||||
["esnext.regexp", "lib.esnext.regexp.d.ts"],
|
||||
["decorators", "lib.decorators.d.ts"],
|
||||
["decorators.legacy", "lib.decorators.legacy.d.ts"],
|
||||
|
||||
@@ -1338,6 +1338,9 @@ export const getScriptTargetFeatures = /* @__PURE__ */ memoize((): ScriptTargetF
|
||||
"from",
|
||||
"of",
|
||||
],
|
||||
esnext: [
|
||||
"fromAsync",
|
||||
],
|
||||
})),
|
||||
ObjectConstructor: new Map(Object.entries({
|
||||
es2015: [
|
||||
|
||||
17
src/lib/esnext.array.d.ts
vendored
Normal file
17
src/lib/esnext.array.d.ts
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
interface ArrayConstructor {
|
||||
/**
|
||||
* Creates an array from an async iterator or iterable object.
|
||||
* @param iterableOrArrayLike An async iterator or array-like object to convert to an array.
|
||||
*/
|
||||
fromAsync<T>(iterableOrArrayLike: AsyncIterable<T> | Iterable<T | PromiseLike<T>> | ArrayLike<T | PromiseLike<T>>): Promise<T[]>;
|
||||
|
||||
/**
|
||||
* Creates an array from an async iterator or iterable object.
|
||||
*
|
||||
* @param iterableOrArrayLike An async iterator or array-like object to convert to an array.
|
||||
* @param mapfn A mapping function to call on every element of itarableOrArrayLike.
|
||||
* Each return value is awaited before being added to result array.
|
||||
* @param thisArg Value of 'this' used when executing mapfn.
|
||||
*/
|
||||
fromAsync<T, U>(iterableOrArrayLike: AsyncIterable<T> | Iterable<T> | ArrayLike<T>, mapFn: (value: Awaited<T>) => U, thisArg?: any): Promise<Awaited<U>[]>;
|
||||
}
|
||||
1
src/lib/esnext.d.ts
vendored
1
src/lib/esnext.d.ts
vendored
@@ -5,4 +5,5 @@
|
||||
/// <reference lib="esnext.promise" />
|
||||
/// <reference lib="esnext.object" />
|
||||
/// <reference lib="esnext.collection" />
|
||||
/// <reference lib="esnext.array" />
|
||||
/// <reference lib="esnext.regexp" />
|
||||
|
||||
@@ -77,6 +77,7 @@
|
||||
"esnext.promise",
|
||||
"esnext.object",
|
||||
"esnext.collection",
|
||||
"esnext.array",
|
||||
"esnext.regexp",
|
||||
"decorators",
|
||||
"decorators.legacy",
|
||||
|
||||
Reference in New Issue
Block a user