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

chainlink

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chainlink

An asynchronous task container.

  • 1.0.0
  • npm
  • Socket score

Version published
Weekly downloads
128
increased by88.24%
Maintainers
1
Weekly downloads
 
Created
Source

An asynchronous task container.

Installation

npm install chain --save

Example

var Chain = require('chainlink');
var chain = new Chain();

chain.link(function(next, arg) {
	console.log(arg);
	next('bar');
});

chain.link(function(next, arg) {
	console.log(arg);
	next('baz');
});

chain.invoke(function(err, arg) {
	console.log(arg);
}, 'foo');

Output:

foo
bar
baz

API

new Chain()

Takes no arguments. Returns a new Chain instance.

.link(callback)

Arguments

  1. callback Function(next, args...): The function to link to the chain.
    • Callbacks will be passed a next() method which must be called, and all of the arguments passed to .invoke() or the last call to next().
    • Any arguments passed to the next() method will be passed to the next callback in the chain.
    • Callbacks can throw an exception synchronously or call the next.error(err) method to skip all remaining callbacks in the chain. The done callback passed to invoke will be called and passed the error as a non-null first argument.

Returns

A reference to the chain.

.unlink(callback)

Arguments

  1. callback Function: The function to unlink from the chain.

Returns

An array of all callbacks unlinked from the chain.

.invoke(done, args...)

Arguments

  1. done Function(err, args...): The function to be called after all callbacks in the chain have been called.
    • The err parameter will be null if no callbacks threw synchronous errors or called the next.error(err) method, otherwise it will be the raised error.
  2. args...: All the arguments passed to the next() method by the last callback in the chain.

Returns

A reference to the chain.

Behavior

Recursion

Callbacks can recursively invoke the chain without any adverse effects.

If a callback calls the link or unlink method of its own chain, the current invocation will not be affected. Future invocations of the chain will reflect the linked or unlinked callbacks.

Keywords

FAQs

Package last updated on 17 Jul 2015

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