mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 11:49:44 +00:00
LibJS: Use HeapFunction for async body closure in Array.fromAsync
This commit is contained in:
parent
e6d1123ce8
commit
716e86f042
Notes:
github-actions[bot]
2024-10-30 19:56:49 +00:00
Author: https://github.com/shannonbooth
Commit: 716e86f042
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2062
Reviewed-by: https://github.com/kalenikaliaksandr ✅
2 changed files with 7 additions and 9 deletions
|
@ -306,7 +306,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayConstructor::from_async)
|
|||
auto promise_capability = MUST(new_promise_capability(vm, realm.intrinsics().promise_constructor()));
|
||||
|
||||
// 3. Let fromAsyncClosure be a new Abstract Closure with no parameters that captures C, mapfn, and thisArg and performs the following steps when called:
|
||||
SafeFunction<Completion()> from_async_closure = [constructor, mapfn, this_arg, &vm, &realm, async_items]() mutable -> Completion {
|
||||
auto from_async_closure = create_heap_function(realm.heap(), [constructor, mapfn, this_arg, &vm, &realm, async_items]() mutable -> Completion {
|
||||
bool mapping;
|
||||
|
||||
// a. If mapfn is undefined, let mapping be false.
|
||||
|
@ -510,10 +510,10 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayConstructor::from_async)
|
|||
// ix. Return Completion Record { [[Type]]: return, [[Value]]: A, [[Target]]: empty }.
|
||||
return Completion { Completion::Type::Return, array };
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
// 4. Perform AsyncFunctionStart(promiseCapability, fromAsyncClosure).
|
||||
async_function_start(vm, promise_capability, from_async_closure);
|
||||
async_function_start(vm, promise_capability, *from_async_closure);
|
||||
|
||||
// 5. Return promiseCapability.[[Promise]].
|
||||
return promise_capability->promise();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue