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.

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to