get-func-name is a specialized utility library within the ChaiJS ecosystem, designed to securely and consistently retrieve the name of a JavaScript function. It offers a single, reliable API that works across both Node.js and browser environments, addressing inconsistencies that can arise from direct property access or varying runtime behaviors. The current stable version is `3.0.0`, which marks a definitive transition to being an ES Module (ESM) exclusively. This follows a previous, temporary ESM introduction and subsequent reversion in the v2.x series. The library maintains a focused release cadence driven by maintenance, bug fixes, and critical updates, such as the security patch in v2.0.1. Its primary differentiator is its cross-platform compatibility and robustness in extracting function names, making it a foundational tool for introspection in testing frameworks and other JavaScript libraries.
npm install get-func-nameVerified import paths — ran on the pinned version, not inferred.
Demonstrates importing `getFuncName` and using it to retrieve names from various function types including named, anonymous, arrow functions, and class methods.
Migrate your import statements from `const getFuncName = require('get-func-name');` to `import { getFuncName } from 'get-func-name';` and ensure your project environment supports ESM (e.g., set `"type": "module"` in `package.json`).Always refer to the latest major version (v3.0.0+) for ESM usage. If strict CommonJS is required, stick to versions `<3.0.0` but be aware of older security fixes.
Upgrade to `get-func-name@2.0.1` or newer. The latest `v3.0.0` also includes this fix and is recommended.
Change your import statement to `import { getFuncName } from 'get-func-name';` and ensure your file is treated as an ES Module (e.g., using `.mjs` extension or `"type": "module"` in `package.json`).Ensure you are using a named import: `import { getFuncName } from 'get-func-name';`. If you are using TypeScript, confirm your `tsconfig.json` `compilerOptions.esModuleInterop` is enabled for better module interoperability.No dependency data recorded yet.