ts-curry Currying Utility

1.0.4 · abandoned · verified Sun Apr 19

ts-curry is a specialized utility library designed for currying functions in TypeScript, providing type-safe currying transformations for functions with up to four arguments. The package's current stable version is 1.0.4, released in July 2018. It has seen no further updates or releases since then, indicating that the project is abandoned. While it offers type safety for currying, its limitation to functions of arity 4 or less, and the lack of maintenance for several years, means it may not be compatible with modern TypeScript versions (e.g., TS 4.x, 5.x) or offer the flexibility of more actively maintained functional programming libraries. Its primary differentiator was its strong TypeScript typing at the time of its release.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates importing `curry2` and applying it to a TypeScript function, showing both single-call and step-by-step curried invocation, along with basic type safety.

import { curry2 } from 'ts-curry';

interface MyDate extends Date {
  getDay(): number;
}

// Define a function with explicit types
const func = (a: number, b: MyDate): number => a + b.getDay();

// Curry the function using curry2
const curried = curry2(func);

// Call the curried function with all arguments at once
const date1: MyDate = new Date('2026-04-19T10:00:00Z') as MyDate; // Example date for consistent output
console.log('Result (all args):', curried(2, date1));

// Call the curried function step-by-step
const partialCurried = curried(2);
const date2: MyDate = new Date('2026-04-20T10:00:00Z') as MyDate; // Another example date
console.log('Result (curried):', partialCurried(date2));

// Type checking ensures correctness (this would error if types mismatch)
// const wrongType = curried('hello', new Date()); // Would cause TypeScript error

view raw JSON →