lazy.js
lazy.js copied to clipboard
Lazy.lines.getIterator() not working
This example prints nothing.
var Lazy = require('lazy.js');
var it = Lazy.readFile("log.txt")
.lines()
.getIterator();
while(it.moveNext()){
console.log(it.current());
}
Altough this example works correctly:
var Lazy = require('lazy.js');
Lazy.readFile("log.txt")
.lines()
.each(function(line){
console.log(line);
});
I'm using version 0.3.1
installed from npm
.
I apologize for not responding to this (directly) sooner. As you can see in the commit from 6 days ago, I have updated the documentation to explain that getIterator
isn't really meant to be used directly. Maybe for that reason I should rename it to _getIterator
or something.
Anyway, I've responded to your question on StackOverflow to hopefully explain what you're seeing here.
Is there any reason you want to use getIterator
instead of each
? Or were you just experimenting?
Than you for you answer.
As i've explained in the StackOverflow
thread, I needed to use getIterator
because I didn't want to read all the lines of a file. I needed to read the first line of n
different files and process the one with the smallest timestamp until there was no lines to read from any file. For that specific scenario I needed to use getIterator
.
Is it possible to implement getIterator
on a Stream Sequence
?