func-compose
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

func-compose

npm version npm downloads bundle Codecov License JSDocs

Compose a new function from smaller functions f(g(x))

Usage

Install package:

# npm
npm install func-compose

# yarn
yarn add func-compose

# pnpm
pnpm install func-compose

Import:

// ESM
import { compose } from "func-compose";

// CommonJS
const { compose } = require("func-compose");

function addOne(x) {
  return x + 1;
}

function multiplyByTwo(x) {
  return x * 2;
}

const result = compose(addOne, multiplyByTwo)(2); // 2 * 2 + 1 = 5

Development

  • Clone this repository
  • Install latest LTS version of Node.js
  • Enable Corepack using corepack enable
  • Install dependencies using pnpm install
  • Run interactive tests using pnpm dev

License

Made with 💛

Published under MIT License.

Readme

Keywords

none

Package Sidebar

Install

npm i func-compose

Weekly Downloads

3

Version

0.0.5

License

MIT

Unpacked Size

5.56 kB

Total Files

6

Last publish

Collaborators

  • iamkhan21