Skip to content

Commit

Permalink
Use promisify-any module's .generators() method
Browse files Browse the repository at this point in the history
  • Loading branch information
overlookmotel committed Jul 18, 2015
1 parent 344ded4 commit a1efa8f
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 15 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@

* Initial code
* Update dependencies
* Use `promisify-any` module's `.generators()` method
8 changes: 4 additions & 4 deletions lib/overlook.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var Utils = require('./utils'),
_ = Utils._;

// exports
module.exports = Utils.promisifyGenerators({
module.exports = promisifyAny.generators({
init: function(options) {
// conform options
if (!options) {
Expand Down Expand Up @@ -172,7 +172,7 @@ module.exports = Utils.promisifyGenerators({
hooks: {
routeBeforePath: function(route) {
// co-wrap all generators
Utils.promisifyGenerators(route);
promisifyAny.generators(route);

// add reference to overlook to route
route.overlook = overlook;
Expand All @@ -188,7 +188,7 @@ module.exports = Utils.promisifyGenerators({
});

// co-wrap all generators
Utils.promisifyGenerators(action);
promisifyAny.generators(action);

// add reference to overlook to action
action.overlook = overlook;
Expand All @@ -212,7 +212,7 @@ module.exports = Utils.promisifyGenerators({
});

// co-wrap all generators
Utils.promisifyGenerators(action);
promisifyAny.generators(action);

// run init function on action
if (action.init) yield action.init();
Expand Down
2 changes: 1 addition & 1 deletion lib/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ var Plugin = module.exports = function(name, params) {

// promisify start function and promisify generators
this.start = promisifyAny(this.start, 1);
Utils.promisifyGenerators(this);
promisifyAny.generators(this);
};
9 changes: 1 addition & 8 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,12 @@
var Promise = require('bluebird'),
co = require('co-bluebird'),
coSeries = require('co-series'),
isGeneratorFn = require('is-generator').fn,
_ = require('lodash');

// exports
var Utils = module.exports = {
_: _,
Promise: Promise,
co: co,
coSeries: coSeries,
promisifyGenerators: function(obj) {
Utils._.forIn(obj, function(fn, fnName) {
if (isGeneratorFn(fn)) obj[fnName] = Utils.co.wrap(fn);
});
return obj;
}
coSeries: coSeries
};
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@
"express": "^4.13.0",
"expressor": "^2.1.1",
"fs-extra-promise": "^0.2.0",
"is-generator": "^1.0.2",
"lodash": "^3.10.0",
"promisify-any": "^1.0.0",
"promisify-any": "^1.1.1",
"require-folder-tree": "^1.4.5",
"walk-folder-tree": "^1.0.0"
},
Expand Down

0 comments on commit a1efa8f

Please sign in to comment.