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

batchify

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

batchify

[![Build Status](https://travis-ci.org/davidmfoley/batchify.svg)](https://travis-ci.org/davidmfoley/batchify) # Batchify

  • 0.1.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

Build Status

Batchify

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)

FAQs

Package last updated on 05 Apr 2014

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