SyncIt Synchronize your Node code
I was working on a proof off concept to a possible replacement for for mongo shell using node.js and one of the requirements was to run existing code of the type.
t = db;t; o = a : 1 ;t; assert;;; oa = 2;t; assert;; // not a very good test of currentOp, but tests that it at least // is sort of there:;
This module is what I came up with. To use do the following.
var Sync = ;// Execute an async method as syncvar result = ;// Result is an object of type {err:.., result:..} mirroring the // callback structure function(err, result) {} // Wrap the originating functionvar readFile = ;var result = ;
API
Syncprototype
- The function is the function you wish to call in a synchronous manner.
- The object is the execution context of the function
- The params is the arguments list passed to the wrapped function
Syncprototype
- The function is the function you wish to wrap.
- The object is the execution context of the function (optional)