For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /reference/function/curry.md.

curry es-toolkit

Curries a function so it can be called with one argument at a time.

const curriedFunc = curry(func);

Usage

curry(func)

Use curry when you want to partially apply a function. The curried function returns a new function until it receives all required arguments. Once all arguments are provided, the original function is executed.

import { curry } from 'es-toolkit/function';

function sum(a: number, b: number, c: number) {
  return a + b + c;
}

const curriedSum = curry(sum);

// Provide value `10` for argument `a`
const sum10 = curriedSum(10);

// Provide value `15` for argument `b`
const sum25 = sum10(15);

// Provide value `5` for argument `c`
// All arguments have been received, so now it returns the value
const result = sum25(5);
// Returns: 30

This is useful for creating reusable functions.

function multiply(a: number, b: number) {
  return a * b;
}

const curriedMultiply = curry(multiply);
const double = curriedMultiply(2);
const triple = curriedMultiply(3);

double(5); // Returns: 10
triple(5); // Returns: 15

Parameters

func(...args: any[]) => anyrequired

The function to curry.

Returns

A curried function that can be called with one argument at a time.

(...args: any[]) => any
Source: es-toolkit

Re-exported verbatim from es-toolkit. Implementation, edge cases, and performance behavior are owned upstream. This page mirrors the documentation at the pinned version; the linked source is authoritative.