GithubHelp home page GithubHelp logo

isabella232 / batch Goto Github PK

View Code? Open in Web Editor NEW

This project forked from visionmedia/batch

0.0 0.0 0.0 70 KB

Simple async batch with concurrency control and progress reporting

License: MIT License

JavaScript 100.00%

batch's Introduction

batch

NPM Version NPM Downloads Build Status Test Coverage

Simple async batch with concurrency control and progress reporting.

Installation

This is a Node.js module available through the npm registry. Installation is done using the npm install command:

$ npm install batch

Usage

var Batch = require('batch')

new Batch([...fns])

Create a new Batch.

batch.concurrency(n)

Set concurrency to n.

batch.end([cb])

Execute all queued functions in parallel, executing cb(err, results).

batch.push(fn)

Queue a function.

batch.throws(throws)

Set wether Batch will or will not throw up.

progress event

Contains the "job" index, response value, duration information, and completion data.

{ index: 1,
  value: 'bar',
  pending: 2,
  total: 3,
  complete: 2,
  percent: 66,
  start: Thu Oct 04 2012 12:25:53 GMT-0700 (PDT),
  end: Thu Oct 04 2012 12:25:53 GMT-0700 (PDT),
  duration: 0 }

Example

var Batch = require('batch')
  , batch = new Batch;

batch.concurrency(4);

ids.forEach(function(id){
  batch.push(function(done){
    User.get(id, done);
  });
});

batch.on('progress', function(e){

});

batch.end(function(err, users){

});

License

MIT

batch's People

Contributors

buschtoens avatar dougwilson avatar forbeslindesay avatar matthewmueller avatar michaelsanford avatar nulltask avatar pdehaan avatar razic avatar stephenmathieson avatar timoxley avatar tj avatar wryk avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.