Socket
Socket
Sign inDemoInstall

batch

Package Overview
Dependencies
77
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.3 to 0.1.0

5

History.md
0.1.0 / 2012-07-03
==================
* add Emitter inheritance and emit "complete" [burcu]
0.0.3 / 2012-06-02

@@ -3,0 +8,0 @@ ==================

18

lib/batch.js
/**
* Module dependencies.
*/
var EventEmitter = require('events').EventEmitter;
/**
* Expose `Batch`.

@@ -13,2 +19,3 @@ */

function Batch() {
EventEmitter.call(this);
this.fns = [];

@@ -21,2 +28,8 @@ for (var i = 0, len = arguments.length; i < len; ++i) {

/**
* Inherit from `EventEmitter.prototype`.
*/
Batch.prototype.__proto__ = EventEmitter.prototype;
/**
* Queue a function.

@@ -44,3 +57,4 @@ *

Batch.prototype.end = function(cb){
var pending = this.fns.length
var that = this
, pending = this.fns.length
, results = []

@@ -55,3 +69,5 @@ , done;

if (err) return done = true, cb(err);
results[index] = res;
that.emit('complete', res, index);
--pending || cb(null, results);

@@ -58,0 +74,0 @@ });

4

package.json
{
"name": "batch"
, "version": "0.0.3"
, "version": "0.1.0"
, "description": "Simple async batch"
, "keywords": []
, "author": "TJ Holowaychuk <tj@vision-media.ca>"

@@ -12,3 +11,2 @@ , "dependencies": {

, "main": "index"
, "engines": { "node": "*" }
}

@@ -24,2 +24,6 @@

batch.on('complete', function(user, i){
// result of the ith job
});
batch.end(function(err, users){

@@ -26,0 +30,0 @@

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