Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including node-interval-stream with all npm packages installed. Try it out:

var nodeIntervalStream = require("node-interval-stream")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

node-interval-stream v1.0.1

Minimal NodeJS readable stream based on intervals

node-interval-stream

npm license github-issues Circle CI build status

Minimal NodeJS readable stream based on intervals

nodei.co

QuickStart


import getIntervalStream from 'node-interval-stream';

var stream = getIntervalStream({
    count: 10,  // iterations
    delay: 250  // ms
});

stream.on('data', data => {
    console.log(data);
}).on('end', () => {
    console.log('finished');
});

Tests

  should receive 0 events in 0ms

    ✔ duration should be 0 < d < 250 and is 106
    ✔ should have 0 entries

  should receive 1 events in 100ms

    ✔ duration should be 100 < d < 250 and is 211
    ✔ should have 1 entries

  should receive 1 events in 10ms

    ✔ duration should be 10 < d < 250 and is 22
    ✔ should have 1 entries

  should receive 10 events in 1000ms

    ✔ duration should be 1000 < d < 1400 and is 1123
    ✔ should have 10 entries

  should receive 10 events in 100ms

    ✔ duration should be 100 < d < 400 and is 126
    ✔ should have 10 entries


  total:     10
  passing:   10
  duration:  2.4s

Author

Julien Bouquillon julien@bouquillon.com http://github.com/revolunet

License

  • MIT : http://opensource.org/licenses/MIT

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free