{"library":"package-name-regex","title":"NPM Package Name Regex Validator","description":"This package provides a highly focused and reliable regular expression specifically designed to validate NPM package names according to the official NPM registry rules. It is currently stable at version 5.0.0 and receives regular maintenance, with major version bumps primarily driven by Node.js End-of-Life (EOL) cycles to ensure compatibility with modern runtime environments. The library differentiates itself by offering a pre-tested, up-to-date regex, saving developers from manually crafting and maintaining complex validation logic, which can be prone to errors as NPM naming conventions evolve. It is a lightweight utility intended for scenarios requiring strict package name validation, such as package managers, build tools, or user input forms, and ships with TypeScript types for enhanced developer experience.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install package-name-regex"],"cli":null},"imports":["import packageNameRegex from 'package-name-regex'","import { packageNameRegex } from 'package-name-regex'","import type { RegExp } from 'package-name-regex'"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import packageNameRegex from 'package-name-regex';\n\nconsole.log('Validating NPM package names:');\nconsole.log(`'some-package' is valid: ${packageNameRegex.test('some-package')}`);\nconsole.log(`'example.com' is valid: ${packageNameRegex.test('example.com')}`);\nconsole.log(`'@npm/thingy' is valid: ${packageNameRegex.test('@npm/thingy')}`);\n\nconsole.log(`'crazy!' is valid: ${packageNameRegex.test('crazy!')}`);\nconsole.log(`'.start-with-period' is valid: ${packageNameRegex.test('.start-with-period')}`);\nconsole.log(`'@npm-zors/money!time.js' is valid: ${packageNameRegex.test('@npm-zors/money!time.js')}`);\n\n// The regex object can be used directly with standard RegExp methods\nconst matchResult = 'another-package'.match(packageNameRegex);\nif (matchResult) {\n  console.log(`'another-package' matched: ${matchResult[0]}`);\n} else {\n  console.log(`'another-package' did not match.`);\n}","lang":"typescript","description":"Demonstrates how to import and use the `packageNameRegex` to test various strings for NPM package name validity.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}