Skip to content

Instantly share code, notes, and snippets.

@jakemcgraw
Last active February 24, 2016 20:18
Show Gist options
  • Select an option

  • Save jakemcgraw/db3b3bbd601499931f50 to your computer and use it in GitHub Desktop.

Select an option

Save jakemcgraw/db3b3bbd601499931f50 to your computer and use it in GitHub Desktop.
Pattern for blue compatible modules
modules.export = (function(){
var Promise = require('bluebird');
var fs = Promise.promisifyAll(require('fs'));
return function(params, cb) {
return fs.doSomeStuffAsync(params)
.then(function(result){
return someOtherAsync(result);
})
.then(function(moreResults){
return someMoreAsync(moreResults);
})
.finally(cb || function(){ });
};
})();
@jakemcgraw
Copy link
Copy Markdown
Author

Thanks for advice! Working it in now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment