Skip to content

Inclusion of numeric argument in receiver instance creation? #22

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

Closed
senocular opened this issue Jan 7, 2022 · 1 comment
Closed

Inclusion of numeric argument in receiver instance creation? #22

senocular opened this issue Jan 7, 2022 · 1 comment
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@senocular
Copy link
Contributor

From readme Generic factory method:

fromAsync can be transferred to or inherited by any other constructor with a single numeric parameter. In that case, the final result will be the data structure created by that constructor (with 0 as its argument)...

While species and of() create arrays with a numeric argument, presumably since they'd be able to have knowledge of predetermined length, shouldn't fromAsync() be consistent with from() since the length of the iterable would/could be unknown?

class Custom extends Array {
    constructor (length) {
        super()
        console.log('Argument length:', length)
    }
}
Custom.from([1,2,3]) // Argument length: undefined
@js-choi js-choi added the question Further information is requested label Jan 7, 2022
@js-choi
Copy link
Collaborator

js-choi commented Jan 7, 2022

Yes, this is a mistake in the explainer. (The specification as written is currently correct, since it is based on Array.from.) I will fix this later.

@js-choi js-choi added bug Something isn't working documentation Improvements or additions to documentation and removed question Further information is requested labels Jan 7, 2022
@js-choi js-choi closed this as completed in cf49c0c Jan 7, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants