neurosity / openbci-observable

Making OpenBCI for Node Reactive
MIT License
37 stars 7 forks source link

Add bufferWindow operator #19

Open alexcastillo opened 7 years ago

alexcastillo commented 7 years ago

We need a way to buffer up to X count and window by Y count every Y. For example:

Let's say we have 512 bins (an array with 512 items) and a window count of 10. We want to buffer until 512 items then on the next 10, add it to the end of the buffer and slice the first 10 items in the buffer (to window). In this example, the first .next is called on item 512, the second .nextis called on item 522 with a total buffer count of 512 since the first 10 were removed. That being said, all .nextwill be called every 10 items except the first one.

I tired OTB RxJS operators bufferCount and windowCount and got close but none of them as far as I'm concerned, are calling .next every skip number.

Does that make sense?