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

compo

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

compo

Compose a queue of functions

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by200%
Maintainers
1
Weekly downloads
 
Created
Source

Compo

Compose a queue of functions. The returns values of the previous function are passed as arguments to the next one.

Installation

npm install compo

Example

var Composer = require('compo');
var composer = new Composer();

composer.add(addOne);
composer.add(addOne);
composer.add(function (num) {
	console.log(num); // 3
});

composer.run(1);

function addOne(num, next) {
	next(num + 1);
}

API

composer.add(fn);

Add a function to the composer queue, if the composer has already run, the function will be automatically dequeued and executed, unless the previous function hasn't finished yet.

fn has a signature of fn(..args, next), where ...args is the returned values of previous function, and next is a callback function that should be called when fn is finished.

You can pass arguments to next(), which will be the returned values of the function. return values directly won't work.

composer.run(..args);

Run the composer, with ...args being passed to the first function in the queue as arguments.

Keywords

FAQs

Package last updated on 31 Jul 2013

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