External: Function

montage/core/extras/function~ Function

Methods

(static) by(relation, compare) → {function}

A utility for creating a comparator function for a particular aspect of a figurative class of objects.
Parameters:
Name Type Description
relation function A function that accepts a value and returns a corresponding value to use as a representative when sorting that object.
compare function an alternate comparator for comparing the represented values. The default is `Object.compare`, which does a deep, type-sensitive, polymorphic comparison.
Source:
Returns:
a comparator that has been annotated with `by` and `compare` properties so `Array#sorted` can perform a transform that reduces the need to call `by` on each sorted object to just once.
Type
function

(static) identity(any) → {Any}

A utility to reduce unnecessary allocations of `function (x) {return x}` in its many colorful but ultimately wasteful parameter name variations.
Parameters:
Name Type Description
any Any value
Source:
Returns:
that value
Type
Any

(static) noop()

A utility to reduce unnecessary allocations of `function () {}` in its many colorful variations. It does nothing and thus makes a suitable default in some circumstances.
Source: