Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Array.fromAsync #4115

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Implement Array.fromAsync #4115

wants to merge 6 commits into from

Conversation

jedel1043
Copy link
Member

@jedel1043 jedel1043 commented Jan 9, 2025

This implements the Array.fromAsync proposal.
Had to create manually crafted state machines to replicate the spec.

@jedel1043 jedel1043 added enhancement New feature or request builtins PRs and Issues related to builtins/intrinsics labels Jan 9, 2025
@jedel1043 jedel1043 added this to the next-release milestone Jan 9, 2025
@jedel1043 jedel1043 requested a review from a team January 9, 2025 07:55
Copy link

github-actions bot commented Jan 9, 2025

Test262 conformance changes

Test result main count PR count difference
Total 50,254 50,254 0
Passed 45,007 45,101 +94
Ignored 1,728 1,634 -94
Failed 3,519 3,519 0
Panics 0 0 0
Conformance 89.56% 89.75% +0.19%
Fixed tests (94):
test/built-ins/Array/fromAsync/mapfn-async-throws.js (previously Ignored)
test/built-ins/Array/fromAsync/asyncitems-arraylike-length-accessor-throws.js (previously Ignored)
test/built-ins/Array/fromAsync/this-constructor-operations.js (previously Ignored)
test/built-ins/Array/fromAsync/mapfn-sync-throws-close-sync-iterator.js (previously Ignored)
test/built-ins/Array/fromAsync/asyncitems-arraylike-promise.js (previously Ignored)
test/built-ins/Array/fromAsync/mapfn-async-throws-close-async-iterator.js (previously Ignored)
test/built-ins/Array/fromAsync/mapfn-result-awaited-once-per-iteration.js (previously Ignored)
test/built-ins/Array/fromAsync/non-iterable-input-element-access-err.js (previously Ignored)
test/built-ins/Array/fromAsync/non-iterable-input-with-thenable.js (previously Ignored)
test/built-ins/Array/fromAsync/asyncitems-array-add-to-singleton.js (previously Ignored)
test/built-ins/Array/fromAsync/asyncitems-uses-intrinsic-iterator-symbols.js (previously Ignored)
test/built-ins/Array/fromAsync/thisarg-omitted-strict.js (previously Ignored)
test/built-ins/Array/fromAsync/mapfn-sync-throws.js (previously Ignored)
test/built-ins/Array/fromAsync/non-iterable-with-thenable-then-method-err.js (previously Ignored)
test/built-ins/Array/fromAsync/sync-iterable-with-thenable-async-mapped-callback-err.js (previously Ignored)
test/built-ins/Array/fromAsync/non-iterable-input-with-thenable-async-mapped-callback-err.js (previously Ignored)
test/built-ins/Array/fromAsync/this-constructor-with-readonly-length.js (previously Ignored)
test/built-ins/Array/fromAsync/thisarg-object.js (previously Ignored)
test/built-ins/Array/fromAsync/async-iterable-async-mapped-awaits-once.js (previously Ignored)
test/built-ins/Array/fromAsync/sync-iterable-with-thenable-element-rejects.js (previously Ignored)
test/built-ins/Array/fromAsync/asyncitems-arraybuffer.js (previously Ignored)
test/built-ins/Array/fromAsync/non-iterable-input-with-thenable-sync-mapped-callback-err.js (previously Ignored)
test/built-ins/Array/fromAsync/this-constructor-with-unsettable-element-closes-async-iterator.js (previously Ignored)
test/built-ins/Array/fromAsync/this-non-constructor.js (previously Ignored)
test/built-ins/Array/fromAsync/name.js (previously Ignored)
test/built-ins/Array/fromAsync/mapfn-not-callable.js (previously Ignored)
test/built-ins/Array/fromAsync/async-iterable-input.js (previously Ignored)
test/built-ins/Array/fromAsync/asyncitems-array-add.js (previously Ignored)
test/built-ins/Array/fromAsync/non-iterable-input-with-thenable-async-mapped-awaits-callback-result-once.js (previously Ignored)
test/built-ins/Array/fromAsync/mapfn-async-iterable-sync.js (previously Ignored)
test/built-ins/Array/fromAsync/this-constructor-with-bad-length-setter.js (previously Ignored)
test/built-ins/Array/fromAsync/asyncitems-iterator-exists.js (previously Ignored)
test/built-ins/Array/fromAsync/asyncitems-function.js (previously Ignored)
test/built-ins/Array/fromAsync/asyncitems-boolean.js (previously Ignored)
test/built-ins/Array/fromAsync/length.js (previously Ignored)
test/built-ins/Array/fromAsync/asyncitems-iterator-not-callable.js (previously Ignored)
test/built-ins/Array/fromAsync/asyncitems-arraylike-holes.js (previously Ignored)
test/built-ins/Array/fromAsync/non-iterable-with-thenable-async-mapped-awaits-once.js (previously Ignored)
test/built-ins/Array/fromAsync/non-iterable-with-non-promise-thenable.js (previously Ignored)
test/built-ins/Array/fromAsync/not-a-constructor.js (previously Ignored)
test/built-ins/Array/fromAsync/asyncitems-asynciterator-throws.js (previously Ignored)
test/built-ins/Array/fromAsync/sync-iterable-with-thenable-sync-mapped-callback-err.js (previously Ignored)
test/built-ins/Array/fromAsync/returns-promise.js (previously Ignored)
test/built-ins/Array/fromAsync/non-iterable-with-thenable-sync-mapped-awaits-once.js (previously Ignored)
test/built-ins/Array/fromAsync/asyncitems-symbol.js (previously Ignored)
test/built-ins/Array/fromAsync/asyncitems-asynciterator-null.js (previously Ignored)
test/built-ins/Array/fromAsync/async-iterable-input-does-not-await-input.js (previously Ignored)
test/built-ins/Array/fromAsync/mapfn-async-arraylike.js (previously Ignored)
test/built-ins/Array/fromAsync/sync-iterable-input-with-non-promise-thenable.js (previously Ignored)
test/built-ins/Array/fromAsync/mapfn-sync-arraylike.js (previously Ignored)
test/built-ins/Array/fromAsync/asyncitems-arraylike-too-long.js (previously Ignored)
test/built-ins/Array/fromAsync/asyncitems-number.js (previously Ignored)
test/built-ins/Array/fromAsync/this-constructor-with-unsettable-element-closes-sync-iterator.js (previously Ignored)
test/built-ins/Array/fromAsync/mapfn-async-iterable-async.js (previously Ignored)
test/built-ins/Array/fromAsync/asyncitems-iterator-null.js (previously Ignored)
test/built-ins/Array/fromAsync/asyncitems-array-add-to-empty.js (previously Ignored)
test/built-ins/Array/fromAsync/asyncitems-string.js (previously Ignored)
test/built-ins/Array/fromAsync/prop-desc.js (previously Ignored)
test/built-ins/Array/fromAsync/asyncitems-asynciterator-exists.js (previously Ignored)
test/built-ins/Array/fromAsync/sync-iterable-with-thenable-async-mapped-awaits-once.js (previously Ignored)
test/built-ins/Array/fromAsync/sync-iterable-with-thenable-sync-mapped-awaits-once.js (previously Ignored)
test/built-ins/Array/fromAsync/this-constructor-with-readonly-elements.js (previously Ignored)
test/built-ins/Array/fromAsync/sync-iterable-with-thenable-awaits-once.js (previously Ignored)
test/built-ins/Array/fromAsync/asyncitems-asynciterator-sync.js (previously Ignored)
test/built-ins/Array/fromAsync/asyncitems-array-remove.js (previously Ignored)
test/built-ins/Array/fromAsync/asyncitems-iterator-promise.js (previously Ignored)
test/built-ins/Array/fromAsync/non-iterable-input.js (previously Ignored)
test/built-ins/Array/fromAsync/mapfn-sync-throws-close-async-iterator.js (previously Ignored)
test/built-ins/Array/fromAsync/mapfn-async-throws-close-sync-iterator.js (previously Ignored)
test/built-ins/Array/fromAsync/sync-iterable-iteration-err.js (previously Ignored)
test/built-ins/Array/fromAsync/non-iterable-input-does-not-use-array-prototype.js (previously Ignored)
test/built-ins/Array/fromAsync/asyncitems-iterator-throws.js (previously Ignored)
test/built-ins/Array/fromAsync/mapfn-sync-iterable-async.js (previously Ignored)
test/built-ins/Array/fromAsync/non-iterable-sync-mapped-callback-err.js (previously Ignored)
test/built-ins/Array/fromAsync/this-constructor.js (previously Ignored)
test/built-ins/Array/fromAsync/asyncitems-null-undefined.js (previously Ignored)
test/built-ins/Array/fromAsync/thisarg-omitted-sloppy.js (previously Ignored)
test/built-ins/Array/fromAsync/async-iterable-input-iteration-err.js (previously Ignored)
test/built-ins/Array/fromAsync/builtin.js (previously Ignored)
test/built-ins/Array/fromAsync/non-iterable-input-with-thenable-element-rejects.js (previously Ignored)
test/built-ins/Array/fromAsync/asyncitems-asynciterator-not-callable.js (previously Ignored)
test/built-ins/Array/fromAsync/sync-iterable-with-thenable-then-method-err.js (previously Ignored)
test/built-ins/Array/fromAsync/asyncitems-object-not-arraylike.js (previously Ignored)
test/built-ins/Array/fromAsync/asyncitems-array-mutate.js (previously Ignored)
test/built-ins/Array/fromAsync/non-iterable-with-thenable-awaits-once.js (previously Ignored)
test/built-ins/Array/fromAsync/asyncitems-bigint.js (previously Ignored)
test/built-ins/Array/fromAsync/this-constructor-with-unsettable-element.js (previously Ignored)
test/built-ins/Array/fromAsync/sync-iterable-input-with-thenable.js (previously Ignored)
test/built-ins/Array/fromAsync/returned-promise-resolves-to-array.js (previously Ignored)
test/built-ins/Array/fromAsync/mapfn-sync-iterable-sync.js (previously Ignored)
test/built-ins/Array/fromAsync/sync-iterable-input.js (previously Ignored)
test/built-ins/Array/fromAsync/thisarg-primitive-strict.js (previously Ignored)
test/built-ins/Array/fromAsync/thisarg-primitive-sloppy.js (previously Ignored)
test/built-ins/Array/fromAsync/asyncitems-operations.js (previously Ignored)

Copy link
Member

@raskad raskad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice implementation!

@raskad raskad requested a review from a team January 11, 2025 02:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
builtins PRs and Issues related to builtins/intrinsics enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants