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

man

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

man

Provides a series of helper functions that allow you to perform asynchronous iteration and flow control.

  • 0.0.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
42
decreased by-22.22%
Maintainers
1
Weekly downloads
 
Created
Source

man

Node.js package. Provides a series of helper functions that allow you to perform asynchronous iteration and flow control.

Installation

npm install man

Callbacks aggregation

If you want to receive results of several callbacks at the same time, use callback() method:

var fs = require('fs'),
    man = require('man'),
    cb = man.callback();

fs.readFile('file1.txt', cb.callback);
fs.readFile('file2.txt', cb.callback);

cb.on(function (err, content) {
    // On each callback.
});

cb.done(function (result1, result2) {
    // When all callbacks have received the results.
});

Serial execution

var man = require('man');

man.do(function () {
    fs.readFile('file1.txt', this.next);
}).do(function (err, content) {
    fs.readFile('file2.txt', this.next);
}).do(function (err, content) {
    // ...
});

Parallel execution

var man = require('man');

man.doAsync(function () {
    // ...
    this.done(result1);
}).do(function () {
    // ...
    this.done(result2);
}).then(function (result1, result2) {
    // ...
});

Iterations

Serial iterations

var man = require('man');

man.for([1, 2, 3, 4, 5]).do(function (number) {
    // On each item.
    this.done(number + 1);
}).then(function (results) {
    // When all items have processed.
    console.log(results); // [2, 3, 4, 5, 6]
});

Parallel iterations

var man = require('man');

man.forAsync([1, 2, 3, 4, 5]).do(function (number) {
    // On each item.
    this.done(number + 1);
}).then(function (results) {
    // When all items have processed.
    console.log(results); // [2, 3, 4, 5, 6]
});

Keywords

FAQs

Package last updated on 25 May 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