The Wayback Machine - https://web.archive.org/web/20210821092824/https://github.com/AssemblyScript/assemblyscript/issues/1966
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

Array.from #1966

Open
trusktr opened this issue Jul 10, 2021 · 3 comments
Open

Array.from #1966

trusktr opened this issue Jul 10, 2021 · 3 comments

Comments

@trusktr
Copy link
Member

@trusktr trusktr commented Jul 10, 2021

Seems like a good first issue, if I'm not underestimating it. (Mind marking it with that label?)

@MaxGraey
Copy link
Member

@MaxGraey MaxGraey commented Jul 10, 2021

Seems like a good first issue

It required function overloading due to Array.from has different signatures with different arity:

from<T>(arrayLike: ArrayLike<T>): T[];
from<T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: i32) => U, thisArg?: any): U[];

and should support also this:

Array.from({ length: 128 }) // ArrayLike interface required only "length"
@trusktr
Copy link
Member Author

@trusktr trusktr commented Jul 18, 2021

I think we can at least have a subset of the functionality. It would be nice for easy cloning at least. Wdyt?

@willemneal
Copy link
Contributor

@willemneal willemneal commented Jul 19, 2021

@MaxGraey This could currently be handled with defaults, except for the thisArg.

from<T, U = T>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: i32) => U = (t: T, k: i32) => t): U[];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment