Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hapi

Package Overview
Dependencies
Maintainers
3
Versions
295
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hapi - npm Package Compare versions

Comparing version 0.15.2 to 0.15.3

40

lib/ext.js

@@ -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 @@ // Declare internals

@@ -0,0 +0,0 @@ // Declare internals

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc