Functional helpers, with Typescript type propagation
npm install @psxcode/arity
import { nullary } from '@psxcode/arity'
const f: (p0: number, p1: string) => boolean
typeof nullary(f) // () => boolean
import { unary } from '@psxcode/arity'
const f: (p0: number, p1: string) => boolean
typeof unary(f) // (p0: number) => boolean
import { binary } from '@psxcode/arity'
const f: (p0: number, p1: string, p2: number) => boolean
typeof binary(f) // (p0: number, p1: string) => boolean
import { ternary } from '@psxcode/arity'
const f: (p0: number, p1: string, p2: number, p3: string) => boolean
typeof ternary(f) // (p0: number, p1: string, p2: number) => boolean
import { voidify } from '@psxcode/arity'
const f: (p0: number, p1: string) => boolean
typeof voidify(f) // (p0: number, p1: string) => void
import { bind } from '@psxcode/arity'
const f: (p0: number, p1: string, p2: boolean) => boolean
typeof bind(10)(f) // (p0: string, p1: boolean) => boolean
typeof bind(10, 'str')(f) // (p1: boolean) => boolean
typeof bind(10, 'str', true)(f) // () => boolean
import { bindCtx } from '@psxcode/arity'
const ctx: { [k: string]: any }
const f: (this: typeof ctx, p0: number) => boolean
typeof bindCtx(ctx)(f) // (p0: number) => boolean
import { bindProps } from '@psxcode/arity'
const props: {
a: number,
b: string
}
const f: (p: typeof props) => boolean
typeof bindProps({ a: 10 })(f) // (p: { b: string }) => boolean
import { curry } from '@psxcode/arity'
const f: (a: number, b: string) => boolean
typeof curry(f) // (a: number) => (b: string) => boolean
import { gather } from '@psxcode/arity'
const f: (p: [number, string, boolean]) => boolean
typeof gather(f) // (p0: number, p1: string, p2: boolean) => boolean
import { spread } from '@psxcode/arity'
const f: (a: number, b: string, c: boolean) => boolean
typeof spread(f) // (args: [number, string, boolean]) => boolean
import { branch } from '@psxcode/arity'
const f0: (a: number) => string
const f1: (a: number) => number
const pred = (a: number) => true
typeof branch(pred, f0) // (a: number) => string | undefined
typeof branch(pred, f0, f1) // (a: number) => string | number
import { and } from '@psxcode/arity'
const f0: (a: number) => boolean
const f1: (a: number) => boolean
typeof and(f0, f1) // (a: number) => boolean
import { or } from '@psxcode/arity'
const f0: (a: number) => boolean
const f1: (a: number) => boolean
typeof or(f0, f1) // (a: number) => boolean
import { noop } from '@psxcode/arity'
typeof noop // () => void
import { identity } from '@psxcode/arity'
typeof identity // <T> (a: T) => T
import { identityAsync } from '@psxcode/arity'
typeof identityAsync // <T> (a: T) => Promise<T>
import { constant } from '@psxcode/arity'
typeof constant // <T> (a: T) => () => T
import { constantAsync } from '@psxcode/arity'
typeof constantAsync // <T> (a: T) => () => Promise<T>