When I try use async it is not defined:
async.whilst(func...);
Then I import it like so, but async is not a module it says:
var async = require('async');
So I then use npm to install it:
npm install async --save
But now when I run code I get error and I am not sure if I've installed the correct module:
.../node_modules/async/dist/async.js:4960
iteratee(next);
^
TypeError: iteratee is not a function
Here is my full code...
var async = require('async');
async.whilst(gameloop);
function gameloop()
{
// I will be adding code here to make it run at 30fps, and use deltatime.
// This will be a gameloop for the multiplayer game I am creating.
console.log('yipee!');
return true;
}
I noticed that yipee! is being logged once and then the error happened.
Has anyone got an idea on how to fix this one?
Thanks in advance,
David.
Edit: Using @nico answer, I got working code: http://pastebin.com/ZCFstqsa
async.whilstexpects two arguments. You are only passing one. The documentation is pretty clear: "Repeatedly calliteratee, whiletestreturns true. Callscallbackwhen stopped, or an error occurs."