Open
Description
list.get(index)
syntax works fine some of the time but it adds up a learning curve + migration cost when you wish swap out arrays in the existing code with lists. I think it would be very nice to put the Proxy like following at the bottom of the prototype chain to allow optional access by index:
let accesor = new Proxy(Object.prototype, {
get(target, property, receiver) {
return receiver.get(property)
}
});
// Workaround to monkey patch loaded immutable.js library, although it should be:
// Iterable.prototype = Object.create(accessor, {....})
Object.setPrototypeOf(Immutable.Iterable.prototype, accesor)
Immutable.List.of(1, 2, 3)[0] // => 1
Immutable.List.of(1, 2, 3)[1] // => 2
Immutable.List.of(1, 2, 3)[5] // => undefined
Immutable.List.of(1, 2, 3)[-2] // => 2