poll-stream

poll a function on an interval emit data

Usage no npm install needed!

<script type="module">
  import pollStream from 'https://cdn.skypack.dev/poll-stream';
</script>

README

node-poll-stream

poll a function on an interval emit data


var poller = require('poll-stream');

poller(function(cb){
  doSomething(cb);
},1000).pipe(process.stdout)

i subtract the time to run the async function from the polling interval to let it sample as close to interval as possible.