Skip to main content
This release is 5 versions behind 1.33.0 — the latest version of @es-toolkit/es-toolkit. Jump to latest

@es-toolkit/es-toolkit@1.29.0-dev.958+1d1d0ee6
Built and signed on GitHub Actions

A modern JavaScript utility library that's 2-3 times faster and up to 97% smaller—a major upgrade to lodash.

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
100%
Published
3 months ago (1.29.0-dev.958+1d1d0ee6)
function iteratee
iteratee(value?: null): <T>(value: T) => T

Returns a identity function when value is null or undefined.

Examples

Example 1

const func = iteratee(); [{ a: 1 }, { a: 2 }, { a: 3 }].map(func) // => [{ a: 1 }, { a: 2 }, { a: 3 }]

Parameters

optional
value: null
  • The value to convert to an iteratee.

Return Type

<T>(value: T) => T
  • Returns a identity function.
iteratee<F extends (...args: any[]) => unknown>(func: F): F

Returns a given func function when value is a function.

Examples

Example 1

const func = iteratee((object) => object.a); [{ a: 1 }, { a: 2 }, { a: 3 }].map(func) // => [1, 2, 3]

Type Parameters

F extends (...args: any[]) => unknown

Parameters

func: F
  • The function to return.

Return Type

  • Returns the given function.
iteratee(value?:
symbol
| number
| string
| object
): (...args: any[]) => any

Creates a function that invokes value with the arguments of the created function.

The created function returns the property value for a given element.

Examples

const func = iteratee('a'); [{ a: 1 }, { a: 2 }, { a: 3 }].map(func) // => [1, 2, 3]

const func = iteratee({ a: 1 }); [{ a: 1 }, { a: 2 }, { a: 3 }].find(func) // => { a: 1 }

const func = iteratee(['a', 1]); [{ a: 1 }, { a: 2 }, { a: 3 }].find(func) // => { a: 1 }

Parameters

optional
value:
symbol
| number
| string
| object
  • The value to convert to an iteratee.

Return Type

(...args: any[]) => any
  • Returns the new iteratee function.

Add Package

deno add jsr:@es-toolkit/es-toolkit

Import symbol

import { iteratee } from "@es-toolkit/es-toolkit/compat";

---- OR ----

Import directly with a jsr specifier

import { iteratee } from "jsr:@es-toolkit/es-toolkit/compat";

Add Package

npx jsr add @es-toolkit/es-toolkit

Import symbol

import { iteratee } from "@es-toolkit/es-toolkit/compat";

Add Package

yarn dlx jsr add @es-toolkit/es-toolkit

Import symbol

import { iteratee } from "@es-toolkit/es-toolkit/compat";

Add Package

pnpm dlx jsr add @es-toolkit/es-toolkit

Import symbol

import { iteratee } from "@es-toolkit/es-toolkit/compat";

Add Package

bunx jsr add @es-toolkit/es-toolkit

Import symbol

import { iteratee } from "@es-toolkit/es-toolkit/compat";