Skip to content

utility

Pipes the value of an expression into a pipeline of functions.

import { expect } from "jsr:@std/expect"
import { pipe } from '@jvlk/fp-tsm'
const len = (s: string): number => s.length
const double = (n: number): number => n * 2
// without pipe
expect(double(len('aaa'))).toBe(6)
// with pipe
expect(pipe('aaa', len, double)).toBe(6)

Performs left-to-right function composition. The first argument may have any arity, the remaining arguments must be unary.

import { expect } from "jsr:@std/expect"
import { flow } from '@jvlk/fp-tsm'
const len = (s: string): number => s.length
const double = (n: number): number => n * 2
const f = flow(len, double)
expect(f('aaa')).toEqual(6)

A set of utility functions for functional programming in TypeScript.