@poppinss/hooks
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -21,2 +21,6 @@ import { IocResolverContract } from '@adonisjs/fold'; | ||
/** | ||
* Returns a boolean whether a handler has been already registered or not | ||
*/ | ||
has(lifecycle: 'before' | 'after', action: string, handler: HooksHandler | string): boolean; | ||
/** | ||
* Register hook handler for a given event and lifecycle | ||
@@ -23,0 +27,0 @@ */ |
@@ -41,2 +41,13 @@ "use strict"; | ||
/** | ||
* Returns a boolean whether a handler has been already registered or not | ||
*/ | ||
has(lifecycle, action, handler) { | ||
const handlers = this.hooks[lifecycle].get(action); | ||
const resolvedHandler = this.resolveHandler(handler); | ||
if (!handlers) { | ||
return false; | ||
} | ||
return handlers.has(resolvedHandler); | ||
} | ||
/** | ||
* Register hook handler for a given event and lifecycle | ||
@@ -43,0 +54,0 @@ */ |
{ | ||
"name": "@poppinss/hooks", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "A no brainer hooks module for execute before/after lifecycle hooks", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
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
12913
158