curry

deno land deno doc GitHub release (latest by date) codecov GitHub

test NPM

Currying and partial application utilities.

currying

curry returns curried function.

import { curry } from "https://deno.land/x/curry@$VERSION/mod.ts";

declare const fn: (a: string, b: number, c: boolean) => void;
const curriedFn = curry(fn);

curriedFn("")(0)(false);
curriedFn("", 0)(false);
curriedFn("", 0, false);

Partial application

Creates a new "bound function".

It has the following characteristics:

  • The length property is 0.
  • The name property is partial.

partial

Partially applies function arguments.

import { partial } from "https://deno.land/x/curry@$VERSION/mod.ts";

declare const fn: (a: string, b: number, c: boolean) => void;

const ternary = partial(fn);
const binary = partial(fn, "");
const unary = partial(fn, "", 0);
const nullary = partial(fn, "", 0, false);

partialRight

Create right partial applied function.

import { partialRight } from "https://deno.land/x/curry@$VERSION/mod.ts";

declare const fn: (a: string, b: number, c: boolean) => void;

const binary = partialRight(fn, false);
const unary = partialRight(fn, false, 0);
const nullary = partialRight(fn, false, 0, "");

partialTail

Create tail partial applied function.

Tail is any argument other than the first argument.

import { partialTail } from "https://deno.land/x/curry@$VERSION/mod.ts";

declare const fn: (a: string, b: number, c: boolean) => void;

const binary = partialTail(fn, 0);
const unary = partialTail(fn, 0, false);

API

See deno doc for all APIs.

License

Copyright © 2023-present Tomoki Miyauchi.

Released under the MIT license