Bug 131698 - Simple ES6 feature: Array.from
Summary: Simple ES6 feature: Array.from
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
Keywords: EasyFix, InRadar
Depends on:
Reported: 2014-04-15 14:56 PDT by Oliver Hunt
Modified: 2016-03-14 12:47 PDT (History)
5 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Oliver Hunt 2014-04-15 14:56:36 PDT

Should be doable in builtin JS
Comment 1 Radar WebKit Bug Importer 2014-04-15 14:56:51 PDT
Comment 2 Antoine Quint 2014-05-07 10:51:46 PDT
Dupe of 130966, landed in http://trac.webkit.org/changeset/167797.

*** This bug has been marked as a duplicate of bug 130966 ***
Comment 3 Antoine Quint 2014-05-07 10:52:30 PDT
Wrong bug, sorry!
Comment 4 Caitlin Potter (:caitp) 2015-01-12 19:18:17 PST
This bug should be simple, but is at least partially blocked on iterators being available.
Comment 5 Oliver Hunt 2015-01-13 08:10:50 PST
We support for-of on all currently iterable types, as well as the spread operator so should be either

Return [...arguments]


Return [...source]

I can't recall spec of the top of my head
Comment 6 Caitlin Potter (:caitp) 2015-01-13 15:09:11 PST
You're correct, for-of and the spread operator are supported for certain types (although strings appear to not be iterable yet in JSC).

However, iterator methods seem to be attached via private properties / internal slots, rather than using the well-known symbol @@iterator.

The Array.from algorithm uses `GetMethod(items, @@iterator)` to determine whether or not it can use the from-iterable path or the from-array-like path, so an implementation is still sort of blocked on that (or at least blocked on exposing a getter for the private iterator properties to JS builtins, if it is to be implemented in JS).
Comment 7 Oliver Hunt 2015-01-13 15:42:48 PST
I would actually say that the hardest part here will be updating the builtins generation logic to support constructor/static functions.

The subsequent logic would be to expose (as a private global) the Symbol object, with @@iterator attached. (You'd still need to use for-of.  Our internal iterator implementation doesn't match spec behaviour for reasons best summed up as "performance")
Comment 8 Oliver Hunt 2015-01-13 15:45:48 PST
note builtin JS can do magical things - look at the js files in builtins/
Comment 9 Geoffrey Garen 2016-03-14 12:47:08 PDT
This is done.
Comment 10 Geoffrey Garen 2016-03-14 12:47:50 PDT