var blah = require('wait.for');
var wait = require('wait.for/parallel-tests');
function testFunction(){
console.log('fiber start');
wait.miliseconds(10*1000);
console.log('fiber end');
};
console.log('app start');
blah.launchFiber(testFunction);
console.log('after launch');
When I try to run the above code I get the following output
app start
fiber start
Z:\nodeplayground\node_modules\wait.for\waitfor.js:15
Fiber( function(){ fn.apply(null, newargs)} ).run(); //launch new fiber,
call the fn with the args, this=null (strict)
^
TypeError: wait.miliseconds is not a function
at testFunction (Z:\nodeplayground\index.js:8:10)
at Z:\nodeplayground\node_modules\wait.for\waitfor.js:15:31
What am I doing wrong?.
The main functionality that I want to achieve is the following
function testFunction2(){
function Innerfunction(){
setTimeout(function(){
console.log("hello");
},5000);
console.log("After setTimeout")
}
}
I want the above code to wait for 5 seconds and print "hello" and after that "After setTimeout".
You try to import
milliseconds
method which is not exported by the modulewait.for/parallel-tests
.You have to declare
wait.milliseconds
function in your main file (or wrap it in a module for reusability).