npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

batchup

v0.0.2

Published

batching for node.js

Downloads

1

Readme

Batchup

Batching for node.js.

Install

npm install --save batchup

Simple usage

For using Batchup you need to require it and create an instance of the library, you can pass set of options which will be explained later in this document but for now you only need to provide a call back function that receives the patched data as an array.

Then the next thing to do is to add your data (can be object variable or what ever) to batchup instance and wait for then to get batched together.

var Batchup = require('batchup')

var options = {
  callback: function(batchedArray) {
    console.log(batchedArray)
    // batchedArray is and array of string 'new data' with length of 1000
  }
}

var batchup = new Batchup(options)

for(var i = 0; i < 1000; i++)
  batchup.add('new data')

Advance usage

Batchup is using an interval to batch the input data together, to use it better it's better to have all the options explained:

options

  • callback: the call back function that will handle the batched data. callback function can return a promise that will tell the batcher to wait and not send any more batch until the promise is ether accepted or rejected.
  • context: context in which the call back should be called by default its the batchup context itself.
  • intervalCycle: interval cycle in millisecond, specifies how often the data needs to be patched. default to 500 millisecond
  • stashLimit: the maximum number of data needs to be stored in case the callback's returned promise is not getting resolved.
  • overflow: function that will be called in case the stash limit has exceed the maximum level and the provided callback function has not responded. by default will emit an error with the data that has overflowed and will continue sending batched to callback function after ten time of interval cycle time to avoid being locked by dead promises. note that the data meanwhile added to batchup will discarded if not handled manually

stoping the cycle

You can stop the batching cycle by calling stop function. in case there is a pending batching this function will 10 second by default to stop the interval but you can specify this value by the input of the function: batchup.stop(5000) // wait to finish for 5 second