node-pluggable
Advanced tools
Comparing version 0.1.2 to 0.1.3
43
index.js
// Generated by CoffeeScript 1.9.1 | ||
(function() { | ||
var EventEmitter, _, async, pluggable, | ||
var EventEmitter, _, async, | ||
slice = [].slice; | ||
@@ -12,8 +12,4 @@ | ||
pluggable = new EventEmitter(); | ||
pluggable.stack = []; | ||
pluggable.match = function(param) { | ||
return _.filter(pluggable.stack, function(arg) { | ||
exports.match = function(param) { | ||
return _.filter(this.stack, function(arg) { | ||
var match_param; | ||
@@ -25,3 +21,3 @@ match_param = arg[0]; | ||
pluggable.use = function() { | ||
exports.use = function() { | ||
var fn, fns, i, len, match_param; | ||
@@ -43,12 +39,12 @@ fns = 1 <= arguments.length ? slice.call(arguments, 0) : []; | ||
fn = fns[i]; | ||
pluggable.stack.push([match_param, fn]); | ||
this.stack.push([match_param, fn]); | ||
} | ||
return pluggable; | ||
return this; | ||
}; | ||
pluggable.del = function() { | ||
exports.del = function() { | ||
var fns, match_param, matched_stack; | ||
match_param = arguments[0], fns = 2 <= arguments.length ? slice.call(arguments, 1) : []; | ||
matched_stack = pluggable.match(match_param); | ||
pluggable.stack = _.filter(matched_stack, function(arg) { | ||
matched_stack = this.match(match_param); | ||
this.stack = _.filter(matched_stack, function(arg) { | ||
var matched_fns, matched_param; | ||
@@ -60,9 +56,9 @@ matched_param = arg[0], matched_fns = arg[1]; | ||
}); | ||
return pluggable; | ||
return this; | ||
}; | ||
pluggable.run = function() { | ||
exports.run = function() { | ||
var callback, i, match_param, params; | ||
match_param = arguments[0], params = 3 <= arguments.length ? slice.call(arguments, 1, i = arguments.length - 1) : (i = 1, []), callback = arguments[i++]; | ||
return async.eachSeries(pluggable.match(match_param), function(arg, callback) { | ||
return async.eachSeries(this.match(match_param), function(arg, callback) { | ||
var fn, match_param; | ||
@@ -78,3 +74,3 @@ match_param = arg[0], fn = arg[1]; | ||
pluggable.bind = function() { | ||
exports.bind = function() { | ||
var fn, fns, i, len, match_param; | ||
@@ -84,8 +80,15 @@ match_param = arguments[0], fns = 2 <= arguments.length ? slice.call(arguments, 1) : []; | ||
fn = fns[i]; | ||
pluggable.on(match_param, fn); | ||
this.on(match_param, fn); | ||
} | ||
return pluggable; | ||
return this; | ||
}; | ||
module.exports = pluggable; | ||
module.exports = function(stack) { | ||
if (stack == null) { | ||
stack = []; | ||
} | ||
return _.extend(new EventEmitter(), _.extend(exports, { | ||
stack: stack | ||
})); | ||
}; | ||
@@ -92,0 +95,0 @@ }).call(this); |
{ | ||
"name": "node-pluggable", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "Add your Hook more easily.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -13,3 +13,3 @@ ## node-pluggable | ||
pluggable = require 'node-pluggable' | ||
pluggable = require('node-pluggable')() | ||
@@ -16,0 +16,0 @@ pluggable.use('article.create', (article, next) -> |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4916
80