bbc / slayer

JavaScript time series spike detection for Node.js and the browser; like the Octave findpeaks function.
https://npmjs.org/slayer
Apache License 2.0
79 stars 16 forks source link

Stream analysis #1

Closed thom4parisot closed 8 years ago

thom4parisot commented 9 years ago

The idea would be to be able to process a buffer stream:

var slayer = require('slayer');
var byline = require('byline');
var fs = require('fs');

var analyser = slayer()
  .y(slayer.buffer.nthColumn(5, ' ')) // 5th column, separated by a space character
  .on('spike', function(spike){
    console.log(spike); // { x: 4, y: 12 }
  });

fs.createReadStream('./data.txt')
  .pipe(byline.LineStream)
  .pipe(analyser.fromStream())
  .pipe(process.stdout);