Module: accessor

accessor

Source:

Methods

<inner> Accessor(get, set) → {Accessor}

Creates an accessor from a getter and a setter. An accessor is a function that is composed of the getter and the setter, and which, if called with one more argument than the number of arguments acceptable by the getter function, calls the setter function, or otherwise calls the getter function. A getter must have at least one argument, the object something is being gotten from. The setter must have at least one more argument than the getter, which is presumably the value that is to be set. The getter and setter the accessor is composed of are available as the accessor.get and accessor.set properties on the accessor function. Using the getter and setter directly should only be done for optimizing accesses when it is really needed. The getter and setter function must not be wrapped by a function that doesn't have the proper number of arguments. Fn.partial() for example returns functions that have a length of 0, and we conciously reject such functions which reduces the potential of difficult to find errors.
Parameters:
Name Type Description
get function
set function
Source:
Returns:
Type
Accessor

<inner> asMethod()

Creates a method accessor from an existing accessor. A method accessor is an acccessor where the accessor function takes one less argument than the acesssor function of a normal accessor, and which uses the `this` special variable in place of the missing argument to pass to the getter and setter.
Source:

<inner> fromString()

Creates an accessor from a string.
Source:

<inner> fromSymbol()

Creates an accessor from a symbol.
Source: