Skip to main content
Module

x/careful/mod.ts>curry

Safe containerization of values for TypeScript
Latest
function curry
import { curry } from "https://deno.land/x/careful@v0.1.0/mod.ts";

This curry function takes in a function fn and returns a curried version of it. When the curried function is called with arguments, it checks if the number of arguments is greater than or equal to the number of arguments the original function fn takes.

Examples

function add(a: number, b: number, c: number) { return a + b + c; } const curriedAdd = curry(add); console.log(curriedAdd(1)(2)(3)); // prints 6 console.log(curriedAdd(1, 2)(3)); // prints 6

Type Parameters

T extends unknown[]
R

Parameters

fn: (...args: T) => R
  • The function to curry.