vexi.js.ProxyList - ProxyList Object

The proxy list object is an alternative list object to the standard js array, which supports a “range trap” lsquo;Elementsrsquo; to trap on the access/assignment/removal of elements

Whereas the Proxy object is very similar to the standard Object the ProxyList is not similar to an array and so cannot be used as a drop in replacement.

Notably, ProxyList does not support most of the methods that arrays have, and it is not sparse and cannot contain nulls. Putting null to a proxy list will remove the object at the index. In this regard, a ProxyList object is similar to a Box in the way it handles manipulation of its contents.

Properties

Property Type Initial Value Description

length

Number

varies

The length of the ProxyList

Elements

N/A

N/A

The Elements property is a meta-property representing a gateway for accessing the properties of the proxylist object.

Placing a trap on this allows the interception of all read and writes to this proxylist object

 // a (range) read trap
 proxylist.Elements ++= function() { };
 // a (range) write trap
 proxylist.Elements ++= function(v) { };

Methods

Method Returns Description

indexOf(element)

Number

The index of an element in the proxylist, or null if the element was not found.

TODO specify behaviour when a modifying readtrap exists

 


Copyright © 2011 The Vexi Project (vexi.sourceforge.net)