This package, `has-async-hooks`, provides a lightweight utility function to programmatically determine if the `async_hooks` API is available in the current Node.js runtime environment. Currently at version 1.0.0, it is a stable, single-purpose library. Its primary differentiator is its simplicity and explicit focus on feature detection for `async_hooks`, which became stable in Node.js 8.0.0. This utility is particularly useful for conditional code execution or polyfilling in environments where compatibility with various Node.js versions (especially older ones) is a concern. The library has a very stable release cadence, with its initial 1.0.0 release being its sole version to date, indicating its 'fire and forget' nature once the feature detection logic is established.
npm install has-async-hooksVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to import and use the has-async-hooks function to check for async_hooks API availability, providing conditional logic for feature-dependent code.
Implement conditional loading or alternative logic based on the `hasAsyncHooks()` return value in your application code.
Be aware of Node.js version compatibility; if your application requires `async_hooks`, ensure a minimum Node.js 8.x environment.
Ensure you are importing the default function correctly: `const hasAsyncHooks = require('has-async-hooks')` for CommonJS or `import hasAsyncHooks from 'has-async-hooks'` for ES Modules.If your project is an ES Module (e.g., `"type": "module"` in package.json), use `import hasAsyncHooks from 'has-async-hooks'` instead of `require('has-async-hooks')`.No dependency data recorded yet.