API reference › @evolu/common › Function › identity
function identity<A>(a: A): A;
Defined in: packages/common/src/Function.ts:120
Returns the value unchanged.
Useful as a default transformation, placeholder callback, or when a function is required but no transformation is needed.
Example
import { identity } from "@evolu/common";
const values = [1, 2, 3];
const object = { value: 1 };
const getTransform = (shouldDouble: boolean) =>
shouldDouble ? (value: number) => value * 2 : identity;
expect(values.map(identity)).toEqual([1, 2, 3]);
expect(identity(object)).toBe(object);
expect(getTransform(false)(2)).toBe(2);