[nodejs] Re: Tidying up callback declarations

2014-01-23 Thread Liam Ryan
Thanks, declaring the expression before the call worked perfectly, I'm still struggling with the function declaration though - var fs = require(fs); fs.readFile( process.argv[2], fileCallback(err, file) ); function fileCallback(err, file) { console.log(file.toString().split(\n).length - 1);

Re: [nodejs] Re: Tidying up callback declarations

2014-01-23 Thread Paul Spencer
Spencer Sent with Airmail From: Liam Ryan Liam Ryan Reply: nodejs@googlegroups.com nodejs@googlegroups.com Date: January 23, 2014 at 6:10:34 AM To: nodejs@googlegroups.com nodejs@googlegroups.com Subject:  [nodejs] Re: Tidying up callback declarations Thanks, declaring the expression before the call

[nodejs] Re: Tidying up callback declarations

2014-01-22 Thread mks
Your callback is a function expression, hence doesn't get hoisted. Write it as a function declaration or move the function expression before the readdir call. On Wednesday, January 22, 2014 7:19:14 PM UTC+1, Liam Ryan wrote: Hi All, Probably a stupid question but I wanted to make my code