Socket
Socket
Sign inDemoInstall

@common-utilities/compose

Package Overview
Dependencies
0
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @common-utilities/compose

A basic implementation of the common utility function, Compose 🚂


Version published
Weekly downloads
1
decreased by-80%
Maintainers
1
Install size
5.19 kB
Created
Weekly downloads
 

Readme

Source

@common-utilities/compose 🧰 🚂

Typed with TypeScript npm version

Compose is a common function composed of function arguments which returns their value to the next function until returning a final value.


Install

yarn add @common-utilities/compose -D

Function

const compose = (...fns) => (val) => fns.reduceRight((fnVal, fn) => fn(fnVal), val)
const compose = (...fns: Function[]) => (val: any) => fns.reduceRight((fnVal: any, fn: Function) => fn(fnVal), val)

Usage

const add1 = (val) => val + 1
const subtract2 = (val) => val - 2
const multiplyBy3 = (val) => val * 3
const result = compose(add1, subtract2, multiplyBy3)
// result(3) // 5 (3 + 1 - 3 * 5)

Common Utilities 🧰

No cruft. No bloat. No dependencies.

Simple, typed, functional, documented, and tested javascript utility functions.


View other common utilities.

FAQs

Last updated on 22 Sep 2020

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