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

jchain

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jchain

  • 0.0.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

jchain - chain javascript functions

Installation

yarn add jchain

Or

npm install jchain

Usage

import chain from 'jchain'
// or
const chain = require('jchain');

// f = 6
const f = chain(
	(next, a, b) => {
		// a = 1, b = 2
		const e = next(3, 4) // e = 5
		return 6
	},
	(next, c, d) => {
		// c = 3, d = 4
		return 5
		// don't call next
	},
	(next) => {
		// next is noop
		// this is not invoked
	},
)(function noop(){}, 1, 2)
  • async/await is support.
  • error is thrown to the outer call.
  • multiple chains can be combined. For e.g.,
chain(
	chain(
		next => {
			// do some thing
			next()
		},
		next => {
			// do some thing
			next()
		},
	),
	chain(
		next => {
			// do some thing
			next() // `next` param of the last chain is what passed to the outer call (`cb` in this case). Default is noop.
		},
	)
)(cb)

FAQs

Package last updated on 23 Aug 2023

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