A lightweight, TypeScript-first functional programming library

~3KB gzipped Auto-curried Zero dependencies 100% tested Tree-shakeable Data-last
import { pipe, map, filter, reduce } from "functional.js";

const data = [1, 2, 3, 4, 5, 6];

const result = pipe(
    data,
    filter(x => x % 2 === 0),
    map(x => x * 2),
    reduce((acc, x) => acc + x)
);

// result: 24

Why functional.js?

Lightweight

Just ~3KB gzipped with excellent tree-shaking support. Ship less JavaScript to your users.

TypeScript-first

Built with TypeScript for TypeScript. Enjoy excellent type inference and autocomplete.

Auto-curried

All functions are automatically curried for point-free programming and composition.

Zero dependencies

No bloat, no supply chain risks. Just pure functional programming utilities.

Tree-shakeable

Modern ESM with excellent tree-shaking. Import only what you need.

Fully tested

100% code coverage with comprehensive test suite. Battle-tested and reliable.

Examples

Using pipe for data transformation

import { pipe, map, filter, reduce } from "functional.js";

const data = [1, 2, 3, 4, 5, 6];

const result = pipe(
    data,
    filter(x => x % 2 === 0),
    map(x => x * 2),
    reduce((acc, x) => acc + x)
);

// result: 24

Building reusable pipelines with flow

import { flow, map, filter } from "functional.js";

interface User {
    name: string;
    age: number;
    active: boolean;
}

const getActiveUserNames = flow(
    filter<User>(u => u.active),
    map(u => u.name.toUpperCase())
);

const users: User[] = [
    { name: "Alice", age: 30, active: true },
    { name: "Bob", age: 25, active: false },
    { name: "Charlie", age: 35, active: true }
];

getActiveUserNames(users);
// ["ALICE", "CHARLIE"]

Currying custom functions

import { curry } from "functional.js";

const add = curry((a: number, b: number) => a + b);

add(1, 2);       // 3
add(1)(2);      // 3

const add5 = add(5);
add5(10);       // 15

Performance

Benchmarks run on Node.js 24.13.0 (macOS), using small/medium/large scenarios with isolated processes, warmups, and median results.

31/45
Benchmark wins
0.81ms
Fastest cold start
3.86x
Speed advantage (max)
1.57x
Average speed ratio
Performance overview

Performance overview across different operations

functional.js speed ratio

functional.js speed ratio compared to competitors

Benchmark wins

functional.js leads in 31 of 45 benchmarks

Memory usage

Memory efficiency comparison

Cold start performance

Cold start performance comparison

Comparison

Library Bundle Size TypeScript Auto-Curry Notes
functional.js ~3KB Strong Data-last, zero dependencies
Ramda ~50KB Limited Data-last, large API
lodash/fp ~24KB Good Data-last wrappers over lodash
underscore ~17KB Limited Data-first utilities
fp-ts ~15KB Strong Types-first, higher learning curve

Ready to get started?

Install functional.js and start writing better functional code today.