func-compose
v0.0.5
Published
Compose a new function from smaller functions `f(g(x))`
Downloads
39
Readme
func-compose
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.