Socket
Socket
Sign inDemoInstall

batch-flood-stream

Package Overview
Dependencies
2
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    batch-flood-stream

emits batches of data events. grouped based on rate they are emitted and a max batch size.


Version published
Weekly downloads
1
Maintainers
1
Install size
21.3 kB
Created
Weekly downloads
 

Readme

Source

batch-flood-stream

emits batches of data events. grouped based on rate they are emitted and a max batch size.

var stream = batch(ondata,options);
  • ondata is optional
  • options are optional
    • size: defaults to 10000 uses data.length or if objects the number of objects
    • wait: defaults to 1000 ms
    • stats: off. if you pass a truthy value batch arrays will have a delay and a rate property.

  var s = batch({wait:5}).on('data',function(batch){
    console.log('data',batch);
  });

  var i = 0;
  var timer = setInterval(function(){
    s.write(++i);
    if(i == 50) {
      clearTimeout(timer);
      s.end();
    }
  },1);

outputs something like

data [ 1 ]
data [ 2 ]
data [ 3, 4 ]
data [ 5, 6, 7 ]
data [ 8 ]
data [ 9, 10, 11 ]
data [ 12, 13, 14, 15 ]
data [ 16, 17 ]
data [ 18, 19, 20 ]
data [ 21, 22, 23, 24 ]
data [ 25, 26 ]
data [ 27, 28, 29 ]
data [ 30, 31, 32 ]
data [ 33, 34, 35 ]
data [ 36, 37, 38, 39 ]
data [ 40, 41, 42 ]
data [ 43, 44, 45, 46 ]
data [ 47, 48, 49 ]

FAQs

Last updated on 24 Apr 2014

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc