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

compose-v

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

compose-v

Variadic function composition

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
10
Maintainers
1
Weekly downloads
 
Created
Source

composeV

codecov Build Status

Composes variadic functions (n-ary). composeV handles unary functions the same as compose ((x) -> (x) -> (x)) -> (x), but can also handle miss-matched arities ((x, y), (x), (x, y, z), ...) -> (x, y, z, ...). Composed functions are nested in parameters[0] while the remaining arguments are passed to parameters[1...]. This can be useful when you need to compose functions while still being able to pass the same arguments into each successive function unchanged.

Note: composeV is non-curried (compose isn't typically). Be sure to reference ramda or a comparable library to make sure there isn't a better fit out there for your particular use-case.

Install

$ npm install --save compose-v

Usage

const composeV = require('compose-v')

// Compose unary functions
const x = x => x + x
const y = x => x * x
const xy = composeV(y, x) // xy :: (a) -> y(x(a))
xy(5) // 100 OR (5 + 5) * 10

// Compose two binary functions
const x = (x, y) => x + y
const y = (x, y) => x * y
const xy = composeV(y, x) // xy :: (a, b) -> y(x(a, b), b)
xy(5, 5) // 50 OR (5 + 5) * 5

// Compose miss-matched n-ary functions
// (Must pass maximum arguments, in this case 3)
const x = (x, y) => x + y
const y = (x, y, z) => x * y * z
const xy = composeV(y, x) // xy :: (a, b, c) -> y(x(a, b, c), b, c)
xy(4, 6, 8) // 24 OR 4 + 6 + 6 + 8

License

MIT © Rob LaFeve

Keywords

FAQs

Package last updated on 14 Jun 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