listUtils

List operator utils module.

Methods

static findIndexWhere(pred, arr) → {Number}

Finds index in string or list.
Parameters:
Name Type Description
pred function Predicate.
arr Array | String
Returns:
Number - - `-1` if predicate not matched else `index` found

static findIndexWhereRight(pred, arr) → {Number}

Finds index in list from right to left.
Parameters:
Name Type Description
pred function Predicate.
arr Array | String
Returns:
Number - - `-1` if predicate not matched else `index` found

static findIndicesWhere(pred, xs) → {Array|undefined}

Parameters:
Name Type Description
pred function
xs Array | String | * list or list like.
Returns:
Array | undefined

static findWhere(pred, xs) → {*}

Parameters:
Name Type Description
pred function
xs Array | String | * list or list like.
Returns:
*

static genericAscOrdering(a, b) → {number}

Generic 'ascending order' ordering function (use by the likes of `list.sort` etc.)
Parameters:
Name Type Description
a *
b *
Returns:
number

static lastIndex(x) → {Number}

Gets last index of a list/list-like (Array|String|Function etc.).
Parameters:
Name Type Description
x Array | String | * list like or list.
Returns:
Number - - `-1` if no element found.

static lengths(lists) → {Array|String|*}

Returns length of all passed lists in list.
Parameters:
Name Type Description
lists Array | String | * ...
Returns:
Array | String | *

static reduce(op, agg, xs) → {*}

Reduces a list with given operation (`op`) function.
Parameters:
Name Type Description
op function Operation - `(agg, item, index, list) => agg`
agg * Zero value.
xs Array | String | * List.
Returns:
*

static reduceRight(op, agg, xs) → {*}

Reduces a list with given operation (`op`) function (from right-to-left).
Parameters:
Name Type Description
op function Operation - `(agg, item, index, list) => agg`
agg * Zero value.
xs Array | String | * List.
Returns:
*

static reduceUntil(pred, op, agg, xs) → {*}

Reduces until predicate.
Parameters:
Name Type Description
pred function `(item, index, list) => Boolean(...)`
op function Operation - `(agg, item, index, list) => agg`
agg * Zero value.
xs Array | String | * List.
Returns:
*

static reduceUntilRight(pred, op, agg, xs) → {*}

Reduces until predicate (from right to left).
Parameters:
Name Type Description
pred function `(item, index, list) => Boolean(...)`
op function Operation - `(agg, item, index, list) => agg`
agg * Zero value.
xs Array | String | * List.
Returns:
*

static sliceFrom(startInd, xs) → {Array|String|*}

Returns a slice of the given list from `startInd` to the end of the list.
Parameters:
Name Type Description
startInd Number
xs Array | String | *
Returns:
Array | String | *

static sliceTo(toInd, xs) → {Array|String|*}

Slices from index `0` to given index.
Parameters:
Name Type Description
toInd Number
xs Array | String | *
Returns:
Array | String | *

static toShortest(…lists) → {Array|String|*}

Returns a list of lists trimmed to the shortest length in given list of lists. @background This method is used by the `zip*` functions to achieve their 'slice to smallest' functionality.
Parameters:
Name Type Attributes Description
lists Array | String | * <repeatable>
Returns:
Array | String | *