mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 17:55:07 +02:00
LibJS: Replace Array.fromAsync with a native JavaScript implementation
This allows us to use the bytecode implementation of await, which
correctly suspends execution contexts and handles completion
injections.
This gains us 4 test262 tests around mutating Array.fromAsync's
iterable whilst it's suspended as well.
This is also one step towards removing spin_until, which the
non-bytecode implementation of await uses.
```
Duration:
-5.98s
Summary:
Diff Tests:
+4 ✅ -4 ❌
Diff Tests:
[...]/Array/fromAsync/asyncitems-array-add-to-singleton.js ❌ -> ✅
[...]/Array/fromAsync/asyncitems-array-add.js ❌ -> ✅
[...]/Array/fromAsync/asyncitems-array-mutate.js ❌ -> ✅
[...]/Array/fromAsync/asyncitems-array-remove.js ❌ -> ✅
```
This commit is contained in:
committed by
Andreas Kling
parent
a63b0cfaba
commit
0eceee0a05
Notes:
github-actions[bot]
2025-11-30 10:56:04 +00:00
Author: https://github.com/Lubrsi Commit: https://github.com/LadybirdBrowser/ladybird/commit/0eceee0a05e Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6728 Reviewed-by: https://github.com/Hendiadyoin1 Reviewed-by: https://github.com/awesomekling
98
Libraries/LibJS/Runtime/JavaScriptImplementations/Builtins.d.ts
vendored
Normal file
98
Libraries/LibJS/Runtime/JavaScriptImplementations/Builtins.d.ts
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
/**
|
||||
* Returns if the given value is callable (i.e. is a function)
|
||||
* @param value {any} Value to check is callable
|
||||
* @returns true if callable, false otherwise
|
||||
*/
|
||||
declare function IsCallable(value: any): boolean;
|
||||
|
||||
/**
|
||||
* Returns if the given value is a constructor
|
||||
* @param value {any} Value to check is a constructor
|
||||
* @returns true if is a constructor, false otherwise
|
||||
*/
|
||||
declare function IsConstructor(value: any): boolean;
|
||||
|
||||
/**
|
||||
* Converts the given value to its object form if it's not already an object.
|
||||
* @param value {any} Value to convert to an object
|
||||
* @returns {@link value} in its object form
|
||||
* @throws {TypeError} If {@link value} is null or undefined
|
||||
*/
|
||||
declare function ToObject(value: any): object;
|
||||
|
||||
/**
|
||||
* Converts the given value to a boolean.
|
||||
* @param value {any} Value to convert to a boolean
|
||||
* @returns {@link value} Value converted to a boolean
|
||||
*/
|
||||
declare function ToBoolean(value: any): boolean;
|
||||
|
||||
/**
|
||||
* Converts the given value to a length.
|
||||
* @param value {any} Value to convert to a length
|
||||
* @returns {@link value} Value converted to a length
|
||||
*/
|
||||
declare function ToLength(value: any): number;
|
||||
|
||||
/**
|
||||
* Throws a {@link TypeError} with the given message.
|
||||
* @param message The reason the error was thrown.
|
||||
* @throws {TypeError} With the given message.
|
||||
*/
|
||||
declare function ThrowTypeError(message: string): never;
|
||||
|
||||
/**
|
||||
* Throws if the given value is an object.
|
||||
* @param value {any} Value to check is an object
|
||||
* @throws {TypeError} If value is not an object
|
||||
*/
|
||||
declare function ThrowIfNotObject(value: any): void;
|
||||
|
||||
/**
|
||||
* Creates a new object with no properties and no prototype.
|
||||
*/
|
||||
declare function NewObjectWithNoPrototype(): object;
|
||||
|
||||
/**
|
||||
* Creates a new TypeError with the given message.
|
||||
*/
|
||||
declare function NewTypeError(message: string): TypeError;
|
||||
|
||||
/**
|
||||
* Creates a new array with a starting length.
|
||||
*/
|
||||
declare function NewArrayWithLength(length: number): Array<any>;
|
||||
|
||||
/**
|
||||
* Creates an AsyncFromSyncIterator object.
|
||||
*/
|
||||
declare function CreateAsyncFromSyncIterator(iterator: object, nextMethod: any, done: boolean): object;
|
||||
|
||||
/**
|
||||
* Creates the given property on the given object with the given value.
|
||||
*/
|
||||
declare function CreateDataPropertyOrThrow(object: object, property: string | number, value: any): undefined;
|
||||
|
||||
/**
|
||||
* Calls the given callee with `this` set to `thisValue` and with the passed in arguments.
|
||||
* @param callee The function to call
|
||||
* @param thisValue The value of `this` to use
|
||||
* @param args The arguments to pass to the function
|
||||
* @returns The result of calling the function
|
||||
*/
|
||||
declare function Call(callee: any, thisValue: any, ...args: any[]): any;
|
||||
|
||||
/**
|
||||
* @defaultValue {@link Symbol.iterator}
|
||||
*/
|
||||
declare const SYMBOL_ITERATOR: symbol;
|
||||
|
||||
/**
|
||||
* @defaultValue {@link Symbol.asyncIterator}
|
||||
*/
|
||||
declare const SYMBOL_ASYNC_ITERATOR: symbol;
|
||||
|
||||
/**
|
||||
* @defaultValue 2 ** 53 - 1
|
||||
*/
|
||||
declare const MAX_ARRAY_LIKE_INDEX: number;
|
||||
Reference in New Issue
Block a user