Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Use ES6 Proxies where available for indexed access on Indexed #440

Copy link
Copy link
Open
@Gozala

Description

@Gozala
Issue body actions

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.