Ah great thank you, I was calling with args and with (), I never thought to 
call the function without parentheses

On Thursday, January 23, 2014 12:36:57 PM UTC, pagameba wrote:
>
> You are invoking fileCallback inside the call to fs.readFile, you just 
> want to provide the function referencer instead.
>
> var fs = require('fs');
>
> fs.readFile(process.argv[2], fileCallback);
>
> function fileCallback(err, file) {
>   console.log(file.toString().split('\n').length - 1);
> }
>
> -- 
> Paul Spencer
> Sent with Airmail
> ------------------------------
> From: Liam Ryan Liam Ryan <javascript:>
> Reply: nod...@googlegroups.com <javascript:> 
> nod...@googlegroups.com<javascript:>
> Date: January 23, 2014 at 6:10:34 AM
> To: nod...@googlegroups.com <javascript:> nod...@googlegroups.com<javascript:>
> Subject:  [nodejs] Re: Tidying up callback declarations 
>
> 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);
> }; 
>
> On Wednesday, January 22, 2014 10:23:49 PM UTC, mks wrote: 
>>
>> 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 for filteredLS 
>>> easier to read by doing something like - 
>>>
>>> var fs = require("fs);
>>>
>>> fs.readdir(process.argv[2], callback);
>>>
>>> var callback = function( err, files) {
>>> ....
>>> }
>>>
>>> However this doesn't seem to work, is it my syntax or will this just not 
>>> work for node?
>>>  
>>    --
> --
> 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 nod...@googlegroups.com <javascript:>
> To unsubscribe from this group, send email to
> nodejs+un...@googlegroups.com <javascript:>
> 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 nodejs+un...@googlegroups.com <javascript:>.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

-- 
-- 
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 nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscr...@googlegroups.com
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 nodejs+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to