Skip to main content
Module

x/curry/mod.ts>curry

Currying and partial application utilities
Latest
variable curry
import { curry } from "https://deno.land/x/curry@1.1.0/mod.ts";

Return curried function.

Examples

Example 1

import { curry } from "https://deno.land/x/curry@$VERSION/mod.ts";
const replace = (from: string, to: string, val: string) => val.replace(from, to)
const curriedReplace = curry(replace)
curriedReplace('hello', 'hi', 'hello world') // 'hi world'
curriedReplace('hello')('hi', 'hello world') // 'hi world'
curriedReplace('hello')('hi')('hello world') // 'hi world'

type

<T extends unknown[], R>(fn: (...args: T) => R) => T["length"] extends 0 ? () => R : Curried<T, R>