Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

compose-funcs

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

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

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8
Maintainers
1
Weekly downloads
 
Created
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

Package last updated on 17 Jul 2017

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc