API reference / @evolu/common / Function / identity

Function: identity()

function identity<A>(a): A;

Defined in: packages/common/src/Function.ts:53

Returns the input value unchanged.

Useful as a default transformation, placeholder callback, or when a function is required but no transformation is needed.

Example

const values = [1, 2, 3];
const same = values.map(identity); // [1, 2, 3]

const getTransform = (shouldDouble: boolean) =>
  shouldDouble ? (x: number) => x * 2 : identity;

Type Parameters

Type Parameter
A

Parameters

ParameterType
aA

Returns

A

Was this page helpful?