Open thegoleffect opened 12 years ago
It's not intentional.
I had the same problem and I looked at the source code. The following code looks suspicious
self.__defineGetter__('lines', function () {
...
if(i>0) chunkArray.push(chunk.slice(lastNewLineIndex, i));
...
By simply removing the guarding if statement seems to solve the problem.
self.__defineGetter__('lines', function () {
...
chunkArray.push(chunk.slice(lastNewLineIndex, i));
...
I'm seeing the same thing. Here's a simple test case that should just echo each line out as is (works fine for non-blank lines, produces undefined
for each blank line if run interactively and 0
if piped):
Lazy = require('lazy');
process.stdin.resume();
process.stdin.setEncoding('utf8');
Lazy(process.stdin)
.lines
.map(String)
.forEach(function(line) {
process.stdout.write(line + '\n');
});
Please, what is the status according to this issue? I'm stuck with that…
Hi @opatry, I was also stuck with this problem and found a fix. Hope my fix also works for you.
Hi @pkrumins, could you please merge my fix and create a release soon, so I can simply install lazy from npm? You can easily check the bug and my fix with the following coffeescript snippet:
lines = ["a", "", "b"]
Lazy = require("lazy")
p = require("child_process").spawn("sh", ["-c", ("echo #{l}" for l in lines).join("; ")])
new Lazy(p.stdout).lines.map(String).join((x) -> console.log (x.join(",") is lines.join(",")), x)
Thanks!
I'm using code like this:
My files have blank lines that are just newline characters. Any lines like that get converted to "\u0030" aka the "0" character. Is this intentional?