to-async
Converts a synchronous function to an asynchronous function
Install
npm install to-async --save
Use
toAsync(target, [cbFirst, [inNextFoop]])
target
target functioncbFirst
specifies callback position in arguments,true
first andfalse
lastinNextFoop
specifies when to run target function
Example
var toAsync = ; { if toThrow throw 'Uppps' } { if err console; return; console;} // Target function will be runned immediately var asyncFunc = ; ;; console; // Target function will be runned in next loop using setImmediate var asyncNextLoopFunc = ; ;; console;