New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

compose-func

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-func

A dependency-free right-to-left compose function (Node v0.10.x compatible)

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

compose-func

A dependency-free right-to-left compose function that will run anywhere

npm has several packages for function composition, and they are all too heavy for my liking. This operation is simple; it doesn't require dependencies, and it doesn't need gulp/grunt to transpile ES6.

This package

  • Has no dependencies
  • Has no build step
  • Is supported by all node environments without any polyfills
  • Has no tests (YAGNI)
  • Is 12 lines of code
  • Works

Usage

var compose = require('compose-func');

var add1 = (x) => x + 1,
mult2 = (x) => x * 2,
square = (x) => x * x;

var compose1 = compose(add1),
compose2 = compose(mult2, add1),
compose3 = compose(square, mult2, add1);

compose1(0); // 1
// === add1(0)

compose2(1); // 4
// === mult2(add1(0))

compose3(1); // 16
// === square(mult2(add1(0)))

Keywords

FAQs

Package last updated on 16 Aug 2016

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