Code Monkey home page Code Monkey logo

ts-pipe-compose's Introduction

Pipe and Compose for TypeScript

pipe, pipeline, and compose functions with TypeScript definitions

What's the point?

This package not only provides simple pipe, pipeline, and compose implementation, it also provides many 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 = pipeline(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

ts-pipe-compose's People

Contributors

cheshireswift avatar ksxgithub avatar renovate-bot avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ts-pipe-compose's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/nodejs.yml
  • actions/checkout v3
  • actions/setup-node v3
npm
package.json
  • @types/fs-extra ^9.0.2
  • @types/jest ^26.0.15
  • @types/node ^14.14.0
  • babel-jest ^26.6.0
  • chalk ^4.1.0
  • clean-typescript-build ^0.1.5
  • cross-env ^7.0.2
  • fs-extra ^11.0.0
  • iter-tools ^6.2.6
  • jest ^26.6.0
  • json5 ^2.1.3
  • pretty-exec ^0.3.10
  • shx ^0.3.2
  • standard ^17.0.0
  • static-type-assert ^4.0.1
  • ts-jest ^26.4.1
  • ts-node ^9.0.0
  • tslint ^6.1.3
  • tslint-config-standard ^9.0.0
  • typescript ^4.0.3
  • yaml-jest ^1.0.5
  • node >= 8.9.0
travis
.travis.yml
  • node 14

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.