import { curry } from "https://deno.land/x/core_fn@v1.0.0-beta.16/deps.ts";
Creates a function that accepts arguments of fn
and either invokes fn
returning its result, if at least arity number of arguments have been provided, or returns a function that accepts the remaining fn
arguments, and so on.
Examples
Example 1
Example 1
const replace = (from: string, to: string, val: string) => val.replace(from, to)
const curriedReplace = curry(replace)
const curriedReplace('hello', 'hi', 'hello world') // 'hi world'
const curriedReplace('hello')('hi', 'hello world') // 'hi world'
const curriedReplace('hello')('hi')('hello world') // 'hi world'