Back to Functions

identity

util

This method returns the first argument it receives.

Installation

Import
import { identity } from '@tulx/utils';

Source Code

Implementation
/**
 * This method returns the first argument it receives.
 *
 * @param value - Any value.
 * @returns Returns value.
 *
 * @example
 * ```ts
 * const object = { 'a': 1 };
 * identity(object) === object; // true
 * ```
 */
export function identity<T>(value: T): T {
  return value;
}

Example

import { identity } from '@tulx/utils';

const object = { 'a': 1 };
identity(object) === object; // true

Related Functions