npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@certes/combinator

v0.1.1

Published

A set of baseline functions in JavaScript.

Downloads

8

Readme

@certes/combinator

Type-safe, pure functional combinators for TypeScript. A comprehensive collection of classical combinatory logic primitives for composable, point-free programming.

[!CAUTION]

⚠️ Active Development & Alpha Status

This repository is currently undergoing active development.

Until 1.0.0 release:

  • Stability: APIs are subject to breaking changes without prior notice.
  • Releases: Current releases (tags/npm packages) are strictly for testing and integration feedback.
  • Production: Do not use this software in production environments where data integrity or high availability is required.

Installation

npm install @certes/combinator

Quick Start

import { compose, pipe, fork, flip } from '@certes/combinator';

// Compose functions right-to-left
const addThenDouble = compose((x: number) => x * 2)((x: number) => x + 3);
addThenDouble(5); // 16 ((5 + 3) * 2)

// Pipe functions left-to-right
const doubleThenAdd = pipe((x: number) => x * 2)((x: number) => x + 3);
doubleThenAdd(5); // 13 ((5 * 2) + 3)

// Fork: apply one value to two functions, combine results
const average = fork((sum: number) => (length: number) => sum / length)
  ((nums: number[]) => nums.reduce((a, b) => a + b, 0))
  ((nums: number[]) => nums.length);

average([1, 2, 3, 4, 5]); // 3

Available Combinators

| Combinator | Name | Lambda | Signature | Description | |------------|------|--------|-----------|-------------| | A | Apply | $\lambda ab.ab$ | (a → b) → a → b | Apply function to argument | | B | Bluebird | $\lambda abc.a(bc)$ | (a → b) → (c → a) → c → b | Function composition (right-to-left) | | BL | Blackbird | $\lambda abcd.a(bcd)$ | (c → d) → (a → b → c) → a → b → d | Compose unary after binary | | C | Cardinal | $\lambda abc.acb$ | (a → b → c) → b → a → c | Flip argument order | | I | Idiot | $\lambda a.a$ | a → a | Identity function | | K | Kestrel | $\lambda ab.a$ | a → b → a | Constant (returns first) | | KI | Kite | $\lambda ab.b$ | a → b → b | Returns second argument | | OR | — | $\lambda abc.(ac) \lor (bc)$ | (a → b) → (a → b) → a → Bool | Logical disjunction | | Phi | Phoenix | $\lambda abcd.a(bd)(cd)$ | (a → b → c) → (d → a) → (d → b) → d → c | Fork combinator | | Psi | — | $\lambda abcd.a(bc)(bd)$ | (b → b → c) → (a → b) → a → a → c | On combinator | | Q | Queer bird | $\lambda abc.b(ac)$ | (a → b) → (b → c) → a → c | Pipe (left-to-right composition) | | S | Starling | $\lambda abc.ac(bc)$ | (a → b → c) → (a → b) → a → c | Substitution | | Th | Thrush | $\lambda ab.ba$ | a → (a → b) → b | Reverse application | | V | Vireo | $\lambda abc.cab$ | a → b → (a → b → c) → c | Pairing | | W | Warbler | $\lambda ab.abb$ | (a → a → b) → a → b | Duplication |

Aliases

// Common functional programming names
import {
  apply,           // A
  compose,         // B
  flip,            // C
  identity,        // I
  constant,        // K
  second,          // KI
  alternation,     // OR
  fork,            // Phi
  on,              // Psi
  pipe,            // Q
  substitution,    // S
  applyTo,         // Th
  pair,            // V
  duplication      // W
} from '@certes/combinator';

Practical Examples

Data Transformation Pipelines

import { pipe } from '@certes/combinator';

// Transform data through multiple steps (left-to-right)
const processUser = pipe
  ((user: { name: string }) => user.name)
  ((name: string) => name.toUpperCase());

processUser({ name: 'alice' }); // 'ALICE'

Partial Application with Flip

import { flip } from '@certes/combinator';

const divide = (a: number) => (b: number) => a / b;
const divideBy10 = flip(divide)(10);

divideBy10(100); // 10 (100 / 10)
divideBy10(50);  // 5  (50 / 10)

Duplicate and Apply

import { duplication } from '@certes/combinator';

const multiply = (a: number) => (b: number) => a * b;
const square = duplication(multiply);

square(7);  // 49 (7 * 7)
square(12); // 144 (12 * 12)

Fork Pattern

import { fork } from '@certes/combinator';

// Calculate variance: E[X²] - E[X]²
const variance = fork
  ((sumSq: number) => (sum: number) => sumSq - sum * sum)
  ((nums: number[]) => nums.reduce((acc, x) => acc + x * x, 0) / nums.length)
  ((nums: number[]) => nums.reduce((acc, x) => acc + x, 0) / nums.length);

variance([1, 2, 3, 4, 5]); // 2

On Combinator (Psi)

import { on } from '@certes/combinator';

// Compare two strings by length
const compareByLength = on
  ((a: number) => (b: number) => a - b)
  ((s: string) => s.length);

compareByLength('hello')('world'); // 0 (same length)
compareByLength('hi')('world');    // -3 (2 - 5)

Substitution Pattern

import { substitution } from '@certes/combinator';

// Apply argument to function and transformed version
const addWithDouble = substitution
  ((a: number) => (b: number) => a + b)
  ((x: number) => x * 2);

addWithDouble(5); // 15 (5 + 10)

Compose vs Pipe

import { compose, pipe } from '@certes/combinator';

const double = (x: number) => x * 2;
const addThree = (x: number) => x + 3;

// Compose: right-to-left (mathematical notation)
compose(addThree)(double)(5); // 13 (addThree(double(5)))

// Pipe: left-to-right (data flow)
pipe(double)(addThree)(5); // 13 (double(5) then addThree)

Theory

These combinators form the basis of combinatory logic, a notation for mathematical logic without variables. The SKI combinator calculus (using S, K, and I) is Turing complete, meaning any computable function can be expressed using only these three combinators.

Key Properties:

  • Pure functions — No side effects, referentially transparent
  • Point-free style — Function composition without explicit parameters
  • Algebraic laws — Combinators satisfy formal algebraic properties

Combinator Identities

// Identity laws
I(x) ≡ x
K(x)(y) ≡ x
KI(x)(y) ≡ y

// Composition
B(f)(g)(x) ≡ f(g(x))
Q(f)(g)(x) ≡ g(f(x))

// Self-application
W(f)(x) ≡ f(x)(x)
V(x)(y)(f) ≡ f(x)(y)

// Distributive
S(f)(g)(x) ≡ f(x)(g(x))
Phi(f)(g)(h)(x) ≡ f(g(x))(h(x))

Further Reading

License

MIT

Contributing

Part of the @certes monorepo. See main repository for contribution guidelines.