The `is-identifier` package provides a highly focused utility to determine if a given string constitutes a valid JavaScript identifier according to ECMAScript specifications. Currently at stable version 1.0.1, this package follows Sindre Sorhus's typical release cadence of infrequent, targeted updates, primarily for bug fixes or minor spec clarifications, ensuring long-term stability. Its key differentiators include precise adherence to the JavaScript identifier rules, including reserved keywords (like `await`) and special global properties (like `globalThis`, `Infinity`, `NaN`, `undefined`) which it correctly treats as invalid identifiers for practical use, despite some not being strictly "keywords". It is a small, dependency-free module optimized for performant identifier validation, contrasting with broader AST parsing libraries.
npm install is-identifierVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to import and use `isIdentifier` to check various strings for JavaScript identifier validity, including valid cases, invalid cases, reserved keywords, and special global properties treated as non-identifiers.
No direct code change is typically required; this fix improves type correctness. Re-check any custom type assertions if issues arise.
Be aware of this specific behavior. If you require identifier validation that permits these global properties (against common best practices), this library might require a wrapper or an alternative.
Always validate context-sensitive keywords like `await` using `isIdentifier` to ensure adherence to general JavaScript identifier rules, independent of execution context.
Ensure you are using `import isIdentifier from 'is-identifier';` (ESM) or `const isIdentifier = require('is-identifier');` (CommonJS) as it is a default export.Verify your import statement: `import isIdentifier from 'is-identifier';` for ESM, or `const isIdentifier = require('is-identifier');` for CommonJS environments.No dependency data recorded yet.