New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@aofl/middleware

Package Overview
Dependencies
Maintainers
2
Versions
142
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aofl/middleware - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0-alpha.4

36

modules/Middleware/index.js

@@ -25,4 +25,9 @@ /**

use(callback, hook) {
if (typeof callback !== 'function') { throw new Error('callback must be a function'); }
if (typeof this.middleware[hook] === 'undefined') { throw new Error(`Only ${Object.keys(this.middleware)} hooks are supported.`); }
if (typeof callback !== 'function') {
throw new Error('callback must be a function');
}
if (typeof this.middleware[hook] === 'undefined') {
throw new Error(`Only ${Object.keys(this.middleware)} hooks are supported.`);
}
this.middleware[hook].push({

@@ -32,2 +37,4 @@ callback,

});
return this.createUnsubscribeFn();
}

@@ -80,4 +87,29 @@

}
/**
* Creates an unsubscribe function
*
* @private
* @param {String} hook
* @param {function} callback
*/
createUnsubscribeFn(hook, callback) {
const unsubscribe = () => {
if (unsubscribe.executed) { return; }
Object.defineProperty(unsubscribe, 'executed', {
value: true
});
const index = this.middleware[hook].indexOf(callback);
/* istanbul ignore else */
if (index > -1) {
this.middleware[hook].splice(index, 1);
}
};
return unsubscribe;
}
}
export default Middleware;

4

package.json
{
"name": "@aofl/middleware",
"version": "2.0.0",
"version": "2.1.0-alpha.4",
"description": "Simple base middleware class",

@@ -24,3 +24,3 @@ "main": "index.js",

},
"gitHead": "91b9b3074f7031a51ce7afa9b542ff5dcfd64997"
"gitHead": "7c4ae57824ce8cec4984c32b93011f7fef10e1b8"
}
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