It just seems wrong to require a third party library just to iterate a file.
On Mon, Apr 14, 2014 at 3:34 PM, Warren Lindsey <[email protected]>wrote: > Good catch on err, I cut too much when stripping it down for email. > > True about edge cases, but I'm not building modules for the masses. It > works perfect in my explicit use case. > > > On Mon, Apr 14, 2014 at 3:23 PM, Aria Stewart <[email protected]> wrote: > >> >> On Apr 14, 02014, at 15:15, Warren Lindsey <[email protected]> >> wrote: >> >> > Split a different way: >> > >> > fs.readFile(myFile, function(err, lines) { >> > if (err) console.log('FILE read file[' + myFile + '] error[' + err >> + ']'); >> > >> > // convert blob to string, split on newline, but split adds empty >> line to end of array, use replace to fix >> > var array = lines.toString().replace(/\n$/, '').split('\n'); >> > console.log('Total lines['+array.length+']'); >> > } >> >> Wow, major gotchas there: Assuming \n isn’t the line-end, that lines >> won’t be null if err is set … ow. >> >> That’ll explode in a lot of edge cases. >> >> > -- -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
