Closed elsehow closed 8 years ago
Hey!
Not sure, I've personally never needed this. I'd like to see what others think. What is your use case, btw? What do you need it for?
Btw, I'd implement it a bit simpler:
function takeNth (stream, n) {
let count = 0
return stream.filter(() => {
count++
return count % n === 0
})
}
This method is inevitably stateful so it's ok to store some state in a closure variable.
Nice solution! I've updated my package.
My use case is taking buffers of EEG data flowing over a serial port:
serialData.slidingWindow(512,512).takeNth(512).map(fft)
I see. .slidingWindow(512,512).takeNth(512)
probably could be replaced with .bufferWithCount(512)
if we'd have bufferWithCount
.
Agreed. I'll try to work on those and maybe issue a PR. Thanks
:+1:
Hi!
I've written a small wrapper to take every nth value of a Kefir stream. I have no idea if my solution is eloquent, but would there be any interest in integrating this feature into Kefir?