Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streaming #11

Open
jwerre opened this issue May 29, 2019 · 1 comment
Open

Streaming #11

jwerre opened this issue May 29, 2019 · 1 comment

Comments

@jwerre
Copy link

jwerre commented May 29, 2019

I'm wondering if there's a way to do this without storing the number array in memory. It would be a nice addition to create a streaming api. Something like:

const stats = require("stats-lite").stream

stat.push(1);
console.log( stats.sum()) // --> 1
stat.push(2);
console.log(stats.sum()) // --> 3
stat.push(3);
console.log(stats.sum()) // --> 6
stat.push(4);
console.log(stats.sum()) // --> 10
stat.push(5);
console.log(stats.sum()) // --> 15

or as a pipe:

const stats = require("stats-lite").stream

readableNumberStream
    .pipe(stats.stdev())

I'm not even sure if that last one is even possible. Can you get the standard deviation without having the entire set of numbers? sum seems pretty straight forward but I'm not sure the other methods could work the same way.

@Odonno
Copy link

Odonno commented Aug 22, 2019

Hi @jwerre

Why not simply use rxjs and use the scan or reduce pipe operator?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants