0.0.8 • Published 6 years ago

throttle-stream v0.0.8

Weekly downloads
514
License
MIT
Repository
-
Last release
6 years ago

Throttle-stream

This is a little bit more modern throttle stream i.e. transform stream that has an ability to control amount of data that is being passed in a unit of time.

Throttle stream extends the native Transform stream class. You can make a new Throttle class instance this way:

  const Throttle = require('throttle-stream');
  const throttle = new Throttle({ bytes: 1000, interval: 100 });

While creating the instance of the class, pass an object as an argument with following properties:

  const options = {
    bytes: 1000, // Integer. Size of a chunk to be read per interval
    interval: 100 // Integer. Time between chunk passing. In miliseconds.
  };

Example

  const Throttle = require('throttle-stream');
  
  const input = getReadableStreamSomehow();
  const output = createWritableStreamSomehow();
  
  input.pipe(new Throttle({ bytes: 6000, interval: 1000 })).pipe(output);

This implementation will send 6000 bytes of data to the output every 1000 miliseconds.

0.0.8

6 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago