jorendorff / js-loaders

Pseudoimplementation of the proposed ES6 module loaders.
54 stars 7 forks source link

Loader.keys() needs better name or definition. #99

Closed johnjbarton closed 10 years ago

johnjbarton commented 10 years ago

Since ES Object.keys() and many other ES function ending in 's' return arrays, devs deserve an array from Loader.keys(). If that is somehow impossible, then we need a better name for the function. An obvious choice would be Loader.keyIterator().

arv commented 10 years ago

Loader implements the Map interface. If you want an array of the keys do:

[...map.keys()]

or

Array.from(map.keys())
jorendorff commented 10 years ago

Agreed.

johnjbarton commented 10 years ago

Loader implements the Map interface, but the API function 'keys()' is inconsistent with the rest of ES6 where keys() returns an array. This kind of inconsistency makes APIs harder to use.

anba commented 10 years ago

Array|Map|Set.prototype.keys() all return Iterator objects, not arrays.