Infinite streams in JavaScript