[![Build Status](]( # Batchify
Last updated 6 years ago by davidmfoley .
Original npm · Tarball · package.json
$ cnpm install batchify 
SYNC missed versions from official npm registry.

Build Status


In some situations, many identical operations can occur in a short period of time, causing performance issues.

Batchify wraps a function so that when it is invoked with identical arguments multiple times while in progress, it will only be invoked once, and all callbacks will be notified when it completes.

  users.findAll(function(err, users) {
    # do something with each user

If there are many concurrent requests that need to look up all of the users, each one will take time and resources to service.

With batchify, one request will be used to service all of the concurrent requests:

  var batchedFindAll = Batchify.wrap(users, 'findAll');

  # Now you use batchedFindAll the same as you would the original function:
  batchedFindAll(function(err, users) { ... });

Batchify invokes users.findAll once and triggers all of the subscribing callbacks when it is finished.

The wrapped function can have parameters too.

(Batchify uses the parameter values as a hash key, so concurrent calls with different parameters will not conflict)

Current Tags

  • 0.1.0                                ...           latest (6 years ago)

2 Versions

  • 0.1.0                                ...           6 years ago
  • 0.0.1                                ...           8 years ago
Maintainers (1)
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 2
Dependencies (0)
Dev Dependencies (4)
Dependents (0)

Copyright 2014 - 2017 © |