Socket
Socket
Sign inDemoInstall

compose-funcs

Package Overview
Dependencies
2
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    compose-funcs

Compose functions (i.e. f(g(x)) -> (f ∘ g)(x)). Returns a function with correct length and a descriptive name


Version published
Maintainers
1
Install size
9.43 kB
Created

Changelog

Source

1.0.0 (2017-07-17)

Features

  • first commit (2ae01d0)

Readme

Source

compose-funcs

Build status NPM version XO code style

Compose functions (i.e. f(g(x)) -> (f ∘ g)(x)). Returns a function with correct length and a descriptive name

Features

  • Composes functions, duh
  • Returns a function with the correct length, i.e. the same length as the rightmost function
  • Returns a function with a descriptive name for easier debugging, e.g:
    compose(f, g, h) -> a function named "f ∘ g ∘ h"
    
  • Returns the identity function when given no arguments to make it extra functional

Installation

Install compose-funcs using npm:

npm install --save compose-funcs

Usage

const compose = require('compose-funcs');

const add = (a, b) => a + b;
const double = a => a * 2;
const doubleAndAdd = compose(double, add);
// doubleAndAdd.length === 2
// doubleAndAdd.name === double ∘ add
doubleAndAdd(3, 4); // the same as: double(add(3, 4))
// (3 + 4) * 2 = 14

API

compose(...functions)

NameTypeDescription
functionsFunctionAny number of functions to compose to a new function

Returns: Function. The composed function.

License

MIT © Joakim Carlstein

Keywords

FAQs

Last updated on 17 Jul 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc