Skip to content

pipe, pipeline, and compose functions with 64 overloads per function.

License

Notifications You must be signed in to change notification settings

KSXGitHub/deno-compose

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overload Definition of Pipe and Compose

pipe, pipeline, and compose functions with 64 overloads per function.

What's the point?

This package not only provides simple pipe, pipeline, and compose implementation, it also provides 64 TypeScript overloads for each function. [See index.d.ts]

Usage

APIs

pipe

Signature: pipe (value, ...functions) → result

const y = pipe(x0, f1, f2, f3)

is equivalent to

const x1 = f1(x0)
const x2 = f2(x1)
const x3 = f3(x2)
const y = f3(x3)

or

const y = f3(f2(f1(x0)))

pipeline

Signature: pipeline (...functions) → function

const fn = pipe(f0, f1, f2, f3)

is equivalent to

const fn = (...args) => f3(f2(f1(f0(...args))))

compose

Signature: compose (...functions) → function

const fn = compose(f3, f2, f1, f0)

is equivalent to

const fn = (...args) => f3(f2(f1(f0(...args))))

composeRight

It is just an alias of pipeline

Example

// pipe
const y0 = pipe(x, f1, f2, f3, f4)

// pipeline
const g1 = pipeline(f0, f1, f2, f3, f4)
const y1 = g1(...args)

// compose
const g2 = compose(f4, f3, f2, f1, f0)
const y2 = g2(...args)

License

MIT © Hoàng Văn Khải