Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign uphow to use wait? #29
Comments
This comment has been minimized.
This comment has been minimized.
contra
commented
May 3, 2013
|
Can you compile this to JS? |
This comment has been minimized.
This comment has been minimized.
legomind
commented
May 3, 2013
var rs, ws;
rs = fs.createReadStream(inFile);
ws = fs.createWriteStream(outFile);
es.pipe( rs,
es.replace(/^[\r\n]+|\.|[\r\n]+$/g, ''),
es.split('\r'),
toObj(inColumns),
transform(),
toCsv(outColumns),
es.replace(/\u001d/g, ''),
es.replace(/^[\r\n]+|\.|[\r\n]+$/g, ''),
ws,
es.wait(function(){
console.log('done');
})
); |
This comment has been minimized.
This comment has been minimized.
|
the problem is that |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
legomind
commented
May 3, 2013
|
@dominictarr unfortunately, your suggestion |
This comment has been minimized.
This comment has been minimized.
timoxley
commented
May 3, 2013
|
@legomind this should work: es.pipe(rs,
es.replace(/^[\r\n]+|\.|[\r\n]+$/g, ''),
// etc
ws
).on('close', function() {
console.log('done')
})
Doesn't actually guarantee the file has closed. Is that acceptable? FYI having the write stream before the end throws in Node 0.10.x: es.pipe(rs,
es.replace(/^[\r\n]+|\.|[\r\n]+$/g, ''),
// etc
ws,
es.wait(function() {console.log('done')})
) // => Error: Cannot pipe. Not readable.
|
This comment has been minimized.
This comment has been minimized.
|
It's time like this you have to read the code. in 0.8 all streams emitted close. I'm not sure why that is a good idea, but: https://github.com/joyent/node/blob/master/lib/fs.js#L1632 there you go. |
This comment has been minimized.
This comment has been minimized.
legomind
commented
May 4, 2013
|
@dominictarr We have a winner! Thanks. I knew it had to be something simple like that! @timoxley I put the Perhaps |
legomind
closed this
May 4, 2013
This comment has been minimized.
This comment has been minimized.
|
hmm, actually, reading the code further still, it looks like close should have worked... |
This comment has been minimized.
This comment has been minimized.
|
@legomind can you please post all the code I need to run this, and reproduce? |
legomind commentedMay 3, 2013
I tried:
The file writes fine, but console.log never gets called. I know this must be something simple, but it escapes me.