
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
A simpler tapable alternative, which can be used to create hooks for plugins.
>_ yarn add hable
>_ npm install hable
Extend your base class from Hable:
import Hookable from 'hable'
export default class MyLib extends Hookable {
constructor() {
// Call to parent to initialize
super()
}
async someFunction() {
// Call and wait for `foo` hooks (if any) sequential
await this.callHook('foo')
// Call and wait for `bar` hooks (if any) in paraller
await this.callHookAsync('bar')
}
}
Inside plugins, register for any hook:
const lib = new MyLib()
// Register a handler for `foo`
lib.hook('foo', async () => { /* ... */ })
// Register multiply handlers at once
lib.hookObj({
foo: async () => { /* ... */ },
bar: [ /* can be also an array */ ]
})
async callHook(name, ...args)
: Used by class itself to sequentially call handlers of a specific hook.async callHookAsync(name, ...args)
: Same as callHook
but calls handlers in parallel.hook(name, fn)
: Used by plugins to register a handler for an specific hook. fn
can be a single function or an array.hookObj(hooksObj)
: Register many hook using an object.$hooks
: An object which maps from each hook name to it's handlers.Extracted from Nuxt.js hooks system. Original author: Sébastien Chopin.
MIT
FAQs
Awaitable hooks for Node.js
The npm package hable receives a total of 82,382 weekly downloads. As such, hable popularity was classified as popular.
We found that hable demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.