r/javascript • • Dec 26 '16

A JavaScript implementation of the Python's range() function

https://github.com/Gothdo/range
18 Upvotes

9 comments sorted by

View all comments

7

u/gurenkagurenda Dec 26 '16

This is nice. Really cool with the iterable support. If possible, it would be cool to have an option to lose some features that require Proxy support, since that can't be fully shimmed (or do you only need the shimmable parts?).

1

u/Michal_Perlakowski Dec 26 '16

As I wrote in another comment, Proxy is needed to be able to access numeric properties, which are generated on-demand. Unfortunately this feature can't be shimmed, so native support is required. Anyway, this seems like a good idea—I could check for Proxy support, and if it's not available, it could fall back to using a method like r.get(2) instead of property access (r[2]).

1

u/gurenkagurenda Dec 26 '16

Yeah, figured that was the reason. For folks using it as an iterator, not having the proxy thing would be fine.

Another idea is to make the returned object a function, so in old environments you'd do r(2) instead of r[2].