@poppinss/hooks
Advanced tools
Comparing version 6.0.1-0 to 6.0.2-0
@@ -19,3 +19,3 @@ "use strict"; | ||
this.withoutHooks = withoutHooks; | ||
this.cleanupActions = new Set(); | ||
this.cleanupActions = []; | ||
/** | ||
@@ -41,3 +41,3 @@ * Find if cleanup call is pending or not. The cleanup is only | ||
const cleanupAction = await handler(...data); | ||
typeof cleanupAction === 'function' && this.cleanupActions.add(cleanupAction); | ||
typeof cleanupAction === 'function' && this.cleanupActions.push(cleanupAction); | ||
} | ||
@@ -51,4 +51,5 @@ } | ||
this.isCleanupPending = false; | ||
for (let action of this.cleanupActions) { | ||
await action(...data); | ||
let startIndex = this.cleanupActions.length; | ||
while (startIndex--) { | ||
await this.cleanupActions[startIndex](...data); | ||
} | ||
@@ -55,0 +56,0 @@ } |
{ | ||
"name": "@poppinss/hooks", | ||
"version": "6.0.1-0", | ||
"version": "6.0.2-0", | ||
"description": "A no brainer hooks module for execute before/after lifecycle hooks", | ||
@@ -32,3 +32,3 @@ "main": "build/index.js", | ||
"@adonisjs/require-ts": "^2.0.9", | ||
"@types/node": "^17.0.15", | ||
"@types/node": "^17.0.18", | ||
"commitizen": "^4.2.4", | ||
@@ -38,4 +38,4 @@ "cz-conventional-changelog": "^3.3.0", | ||
"doctoc": "^2.0.1", | ||
"eslint": "^8.8.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint": "^8.9.0", | ||
"eslint-config-prettier": "^8.4.0", | ||
"eslint-plugin-adonis": "^2.1.0", | ||
@@ -42,0 +42,0 @@ "eslint-plugin-prettier": "^4.0.0", |
@@ -118,2 +118,4 @@ <div align="center"><img src="https://res.cloudinary.com/adonisjs/image/upload/q_100/v1557762307/poppinss_iftxlt.jpg" width="600px"></div> | ||
Also, the cleanup hooks runs in the reverse order. So the cleanup function for the first hook will run last. | ||
## Passing data to hooks | ||
@@ -120,0 +122,0 @@ You can pass data to hooks at the time of running the `run` and the `cleanup` functions. For example. |
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
17937
269
185