javascript - Wrap library with thunkify for co -


i wondering how thunkify (wrap in thunk) library use co. library following. client calls use other objects in library.

library.client = function(opts) { }  library.client.prototype.createlist = function(opts, cb) {   options.client = this;    var list = new library.list(opts, function(err, data) {     if (typeof(cb) === 'function') {       cb(err, list, data);     }   }); }  library.list = function(opts, cb) {   // setup opts    if (cb) this.fetch(cb); }  library.list.prototype.fetch = function(cb) {   var list = [1,2];// list   (var = 0; < list.length; i++) {     list[i] = new library.item(list[i]);   });   if (typeof(cb) === 'function') cb(err, data); }  library.item = function(opts) { }  exports.client = library.client; exports.list = library.list; exports.item = library.item; 

then use library this.

var client = new library.client(opts); client.createlist(); 

here's library want:

https://www.npmjs.org/package/thunkify-wrap


Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -