Socket
Socket
Sign inDemoInstall

batch

Package Overview
Dependencies
0
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.4.0 to 0.5.0

4

component.json
{
"name": "batch",
"repo": "component/batch",
"repo": "visionmedia/batch",
"description": "Async task batching",
"version": "0.3.2",
"version": "0.5.0",
"keywords": ["batch", "async", "utility", "concurrency", "concurrent"],

@@ -7,0 +7,0 @@ "dependencies": {

0.5.0 / 2013-07-29
==================
* add `.throws(true)` to opt-in to responding with an array of error objects
* make `new` optional
0.4.0 / 2013-06-05

@@ -3,0 +9,0 @@ ==================

@@ -1,2 +0,1 @@

/**

@@ -29,4 +28,6 @@ * Module dependencies.

function Batch() {
if (!(this instanceof Batch)) return new Batch;
this.fns = [];
this.concurrency(Infinity);
this.throws(true);
for (var i = 0, len = arguments.length; i < len; ++i) {

@@ -74,2 +75,14 @@ this.push(arguments[i]);

/**
* Set wether Batch will or will not throw up.
*
* @param {Boolean} throws
* @return {Batch}
* @api public
*/
Batch.prototype.throws = function(throws) {
this.e = !!throws;
return this;
};
/**
* Execute all queued functions in parallel,

@@ -88,5 +101,7 @@ * executing `cb(err, results)`.

, results = []
, errors = []
, cb = cb || noop
, fns = this.fns
, max = this.n
, throws = this.e
, index = 0

@@ -113,3 +128,3 @@ , done;

if (done) return;
if (err) return done = true, cb(err);
if (err && throws) return done = true, cb(err);
var complete = total - pending + 1;

@@ -119,2 +134,3 @@ var end = new Date;

results[i] = res;
errors[i] = err;

@@ -124,2 +140,3 @@ self.emit('progress', {

value: res,
error: err,
pending: pending,

@@ -135,2 +152,3 @@ total: total,

if (--pending) next()
else if(!throws) cb(errors, results);
else cb(null, results);

@@ -137,0 +155,0 @@ }

{
"name": "batch"
, "version": "0.4.0"
, "version": "0.5.0"
, "description": "Simple async batch"

@@ -5,0 +5,0 @@ , "author": "TJ Holowaychuk <tj@vision-media.ca>"

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