Comparing version 0.15.2 to 0.15.3
@@ -35,2 +35,4 @@ // Load modules | ||
var self = this; | ||
options = options || {}; | ||
@@ -40,22 +42,32 @@ | ||
this._events[event] = this._events[event] || [] | ||
// Validate rules | ||
var ext = { | ||
priority: this._events[event].length, | ||
before: [].concat(options.before || []), | ||
after: [].concat(options.after || []), | ||
group: plugin || '?', | ||
func: func | ||
}; | ||
var before = [].concat(options.before || []); | ||
var after = [].concat(options.after || []); | ||
var group = plugin || '?'; | ||
// Validate rules | ||
Utils.assert(before.indexOf(group) === -1, 'Plugin ext cannot come before itself (' + group + ')'); | ||
Utils.assert(before.indexOf('?') === -1, 'Plugin ext cannot come before unassociated exts'); | ||
Utils.assert(after.indexOf(group) === -1, 'Plugin ext cannot come after itself (' + group + ')'); | ||
Utils.assert(after.indexOf('?') === -1, 'Plugin ext cannot come after unassociated exts'); | ||
Utils.assert(ext.before.indexOf(ext.group) === -1, 'Plugin ext cannot come before itself (' + ext.plugin + ')'); | ||
Utils.assert(ext.before.indexOf('?') === -1, 'Plugin ext cannot come before unassociated exts'); | ||
Utils.assert(ext.after.indexOf(ext.group) === -1, 'Plugin ext cannot come after itself (' + ext.plugin + ')'); | ||
Utils.assert(ext.after.indexOf('?') === -1, 'Plugin ext cannot come after unassociated exts'); | ||
// Add functions | ||
this._events[event] = this._events[event] || []; | ||
([].concat(func)).forEach(function (fn, i) { | ||
var ext = { | ||
priority: self._events[event].length, | ||
before: before, | ||
after: after, | ||
group: group, | ||
func: fn | ||
}; | ||
self._events[event].push(ext); | ||
}); | ||
// Insert event | ||
this._events[event].push(ext); | ||
var error = this.sort(event); | ||
@@ -62,0 +74,0 @@ Utils.assert(!error, event + ' extension' + (plugin ? ' add by ' + plugin : '') + ' created a dependencies error'); |
@@ -0,0 +0,0 @@ // Load modules |
@@ -0,0 +0,0 @@ // Load modules |
@@ -0,0 +0,0 @@ // Load modules |
@@ -0,0 +0,0 @@ // Load modules |
@@ -0,0 +0,0 @@ // Load modules |
@@ -0,0 +0,0 @@ // Load modules |
@@ -0,0 +0,0 @@ // Load modules |
@@ -5,3 +5,3 @@ { | ||
"homepage": "http://hapijs.com", | ||
"version": "0.15.2", | ||
"version": "0.15.3", | ||
"author": "Eran Hammer <eran@hueniverse.com> (http://hueniverse.com)", | ||
@@ -8,0 +8,0 @@ "contributors": [ |
@@ -0,0 +0,0 @@ // Load modules |
@@ -23,3 +23,3 @@ // Load modules | ||
describe('onRequest', function (done) { | ||
describe('#onRequest', function (done) { | ||
@@ -43,2 +43,30 @@ it('replies with custom response', function (done) { | ||
}); | ||
describe('#ext', function () { | ||
it('supports adding an array of ext methods', function (done) { | ||
var server = new Hapi.Server(); | ||
server.ext('onPreHandler', [ | ||
function (request, next) { | ||
request.x = '1'; | ||
next(); | ||
}, | ||
function (request, next) { | ||
request.x += '2'; | ||
next(); | ||
} | ||
]); | ||
server.route({ method: 'GET', path: '/', handler: function () { this.reply(this.x); } }); | ||
server.inject({ method: 'GET', url: '/' }, function (res) { | ||
expect(res.result).to.equal('12'); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}); |
@@ -0,0 +0,0 @@ // Load modules |
@@ -0,0 +0,0 @@ // Declare internals |
@@ -0,0 +0,0 @@ { |
@@ -0,0 +0,0 @@ // Declare internals |
@@ -0,0 +0,0 @@ { |
@@ -0,0 +0,0 @@ // Declare internals |
@@ -0,0 +0,0 @@ { |
@@ -0,0 +0,0 @@ // Declare internals |
@@ -0,0 +0,0 @@ // Declare internals |
@@ -0,0 +0,0 @@ // Declare internals |
@@ -0,0 +0,0 @@ // Load modules |
@@ -0,0 +0,0 @@ // Load modules |
@@ -0,0 +0,0 @@ // Load modules |
@@ -0,0 +0,0 @@ // Load modules |
@@ -0,0 +0,0 @@ // Load modules |
@@ -0,0 +0,0 @@ // Load modules |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
13065
763649