Global

Methods

get()

Never allow get in a setter

get(path, unsafe) → {function}

Safely get a value from a path (as an array or a dot-delimited string).

Parameters:
Name Type Description
path string | Array

Array or dot-delimited string describing a path to follow in an object

unsafe boolean

If true, fails if element at path doesn't exist

Returns:
Type
function

get(i, j) → {function}

Get the slice of an array from i to j.

Parameters:
Name Type Description
i int

The start of the slice

j int

The end of the slice

Returns:
Type
function

get(index, unsafe) → {function}

Get the element at a specific index of an array

Parameters:
Name Type Description
index int

The index to get

unsafe boolean

If true, throw an error if index is invalid

Returns:

The get function required to construct a Lens

Type
function

IdLens()

The simplest possible Lens: operates on a single object; get returns the object and map applies a function to it and returns the result.

map()

Never allow map in a getter

map(i, j) → {function}

Map a function over a slice of an array and return the modified array.

Parameters:
Name Type Description
i int

The start of the slice (may be negative)

j int

The end of the slice (may be negative)

Returns:
Type
function

map(path, unsafe) → {function}

Map a function over a value gotten from some path in the object and return a new object.

Parameters:
Name Type Description
path string | Array

Array or dot-delimited string describing a path to follow in an object

unsafe boolean

If true, fails if element at path doesn't exist

Returns:
Type
function

map(index, unsafe) → {function}

Map a function over the value at some index in an array. Index must be in the interval [0, array.length] (inclusive); i.e. you may only modify existing elements or add an element to the end.

Parameters:
Name Type Description
index int

The index to map over

unsafe boolean

If true, throw an error if index isn't valid.

Returns:

The map function required to construct a Lens

Type
function