Saturday 24 November 2018

Help with transform stream newbie here

I have 1m ohlc data coming live from a ws data source. I am trying to convert it to 5m 15m 30m 1h etc and am confused about something. I read the docs and understood that I implement a _transform method that takes input and calls a callback. Should my _transform method convert incoming data into all timeframes and push each one or should I have multiple Transform instances where each one does one specific conversionApproach 1 One Transform stream that pushes alllet r= new Source()let t = new Transform({_transform(chunk, encoding, done){this.push(data['5m'])this.push(data['15m'])...}})Approach 2 Multiple Transform Streamslet r = new Source()let t5 = new Transform("5m")let t15 = new Transform("15m")r.pipe(t5)r.pipe(t15)I noticed that I cannot nest pipe calls because it goes from output to input but I want 1m as input to eachThe second approach seems like it loops through all 'data' event listeners and fires each oneWhat is the right way to do this and is there a better approach? Thank you in advance

Submitted November 24, 2018 at 04:55PM by mypirateapp

No comments:

Post a Comment