{"_id":"to-valid-identifier","_rev":"3-0277dfc1aab1f7a12d3a8d5138266651","name":"to-valid-identifier","dist-tags":{"latest":"1.0.0"},"versions":{"0.1.0":{"name":"to-valid-identifier","version":"0.1.0","keywords":["valid","identifier","safe","sanitize","variable","property","ecmascript","javascript","js","reserved","keyword","word","property"],"author":{"url":"https://sindresorhus.com","name":"Sindre Sorhus","email":"sindresorhus@gmail.com"},"license":"MIT","_id":"to-valid-identifier@0.1.0","maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"homepage":"https://github.com/sindresorhus/to-valid-identifier#readme","bugs":{"url":"https://github.com/sindresorhus/to-valid-identifier/issues"},"dist":{"shasum":"baddd75dd1d30e8666171ec81b55169425a03906","tarball":"https://registry.npmjs.org/to-valid-identifier/-/to-valid-identifier-0.1.0.tgz","fileCount":5,"integrity":"sha512-R8KA0Ft5lk4W6eOKc1L8tJIZZofHVQHo3gEPkn3yuqISfGTHKPTlD4TIaLsycjalQplOaNw+CloEc05SDsHaxQ==","signatures":[{"sig":"MEQCIHOzzZSvhURPUb94D+9jFQx3KnobId16pXHRALe0adJdAiBXg5S2MoUogmOkbHYVUp/PTOsRY81yC6TurLdda3DMdQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":4541},"type":"module","types":"./index.d.ts","engines":{"node":">=18"},"exports":{"types":"./index.d.ts","default":"./index.js"},"funding":"https://github.com/sponsors/sindresorhus","gitHead":"ff135dc688c01fb88aebc08858e00ddd1bad3f16","scripts":{"test":"xo && ava"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"repository":{"url":"git+https://github.com/sindresorhus/to-valid-identifier.git","type":"git"},"_npmVersion":"10.6.0","description":"Convert a string to a valid JavaScript identifier","directories":{},"sideEffects":false,"_nodeVersion":"20.12.2","dependencies":{"@sindresorhus/base62":"^0.1.0","reserved-identifiers":"^1.0.0"},"_hasShrinkwrap":false,"devDependencies":{"xo":"^0.58.0","ava":"^6.1.2"},"_npmOperationalInternal":{"tmp":"tmp/to-valid-identifier_0.1.0_1714933927495_0.19167055756430007","host":"s3://npm-registry-packages"}},"0.1.1":{"name":"to-valid-identifier","version":"0.1.1","keywords":["valid","identifier","safe","sanitize","variable","property","ecmascript","javascript","js","reserved","keyword","word","property"],"author":{"url":"https://sindresorhus.com","name":"Sindre Sorhus","email":"sindresorhus@gmail.com"},"license":"MIT","_id":"to-valid-identifier@0.1.1","maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"homepage":"https://github.com/sindresorhus/to-valid-identifier#readme","bugs":{"url":"https://github.com/sindresorhus/to-valid-identifier/issues"},"dist":{"shasum":"bfd09b8c63ab0c0235e23c8243f7630f45b3e7a9","tarball":"https://registry.npmjs.org/to-valid-identifier/-/to-valid-identifier-0.1.1.tgz","fileCount":5,"integrity":"sha512-/m+BsP+oLrdYptSVuWdRanXBD0N1qiyx2GtAunpPz+TRPENw7IpEndqyPTwxe67wLiu16ZinauXESdOL1eDYBQ==","signatures":[{"sig":"MEUCIFq0WQHUzSerAvxeEzxNZsyMwj3m+2tkjVTp0y9at9ZnAiEAi3Loo6SZWpkSC2WywqXc6D9s8eEVJCYRn//brTb+BYM=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":4532},"type":"module","types":"./index.d.ts","engines":{"node":">=18"},"exports":{"types":"./index.d.ts","default":"./index.js"},"funding":"https://github.com/sponsors/sindresorhus","gitHead":"06962df047ebf79021f09215bff3501b8e4b53be","scripts":{"test":"xo && ava"},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"repository":{"url":"git+https://github.com/sindresorhus/to-valid-identifier.git","type":"git"},"_npmVersion":"10.6.0","description":"Convert a string to a valid JavaScript identifier","directories":{},"sideEffects":false,"_nodeVersion":"18.20.2","dependencies":{"@sindresorhus/base62":"^0.1.0","reserved-identifiers":"^1.0.0"},"_hasShrinkwrap":false,"devDependencies":{"xo":"^0.58.0","ava":"^6.1.2"},"_npmOperationalInternal":{"tmp":"tmp/to-valid-identifier_0.1.1_1716892630763_0.09631021252624206","host":"s3://npm-registry-packages"}},"1.0.0":{"name":"to-valid-identifier","version":"1.0.0","description":"Convert a string to a valid JavaScript identifier","license":"MIT","repository":{"type":"git","url":"git+https://github.com/sindresorhus/to-valid-identifier.git"},"funding":"https://github.com/sponsors/sindresorhus","author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"type":"module","exports":{"types":"./index.d.ts","default":"./index.js"},"sideEffects":false,"engines":{"node":">=20"},"scripts":{"test":"xo && ava"},"keywords":["valid","identifier","safe","sanitize","variable","property","ecmascript","javascript","js","reserved","keyword","word","property"],"dependencies":{"@sindresorhus/base62":"^1.0.0","reserved-identifiers":"^1.0.0"},"devDependencies":{"ava":"^6.4.1","xo":"^1.2.3"},"gitHead":"27f29b8e452f09f4af039bab5c48d8f194ba65f3","types":"./index.d.ts","_id":"to-valid-identifier@1.0.0","bugs":{"url":"https://github.com/sindresorhus/to-valid-identifier/issues"},"homepage":"https://github.com/sindresorhus/to-valid-identifier#readme","_nodeVersion":"24.9.0","_npmVersion":"11.6.1","dist":{"integrity":"sha512-41wJyvKep3yT2tyPqX/4blcfybknGB4D+oETKLs7Q76UiPqRpUJK3hr1nxelyYO0PHKVzJwlu0aCeEAsGI6rpw==","shasum":"27337955333c3c517feb60bea533cf27ce54b79f","tarball":"https://registry.npmjs.org/to-valid-identifier/-/to-valid-identifier-1.0.0.tgz","fileCount":5,"unpackedSize":4621,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIEwpt7ciILXsyEO2OP7W3/ohyzBusrHJxxMUSnyUer7MAiAE0Nz6lMDW+9nHtST7jzfO+Eu5975w+t8srm+kLfdxMw=="}]},"_npmUser":{"name":"sindresorhus","email":"sindresorhus@gmail.com"},"directories":{},"maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/to-valid-identifier_1.0.0_1760495018649_0.17480167179009287"},"_hasShrinkwrap":false}},"time":{"created":"2024-05-05T18:32:07.494Z","modified":"2025-10-15T02:23:39.090Z","0.1.0":"2024-05-05T18:32:07.648Z","0.1.1":"2024-05-28T10:37:10.914Z","1.0.0":"2025-10-15T02:23:38.881Z"},"bugs":{"url":"https://github.com/sindresorhus/to-valid-identifier/issues"},"author":{"name":"Sindre Sorhus","email":"sindresorhus@gmail.com","url":"https://sindresorhus.com"},"license":"MIT","homepage":"https://github.com/sindresorhus/to-valid-identifier#readme","keywords":["valid","identifier","safe","sanitize","variable","property","ecmascript","javascript","js","reserved","keyword","word","property"],"repository":{"type":"git","url":"git+https://github.com/sindresorhus/to-valid-identifier.git"},"description":"Convert a string to a valid JavaScript identifier","maintainers":[{"name":"sindresorhus","email":"sindresorhus@gmail.com"}],"readme":"# to-valid-identifier\n\n> Convert a string to a valid [JavaScript identifier](https://developer.mozilla.org/docs/Glossary/Identifier)\n\n## Install\n\n```sh\nnpm install to-valid-identifier\n```\n\n## Usage\n\n```js\nimport toValidIdentifier from 'to-valid-identifier';\n\ntoValidIdentifier('foo');\n//=> 'foo'\n\ntoValidIdentifier('foo-bar');\n//=> 'foo$j$bar'\n\ntoValidIdentifier('$');\n//=> '$a$'\n\ntoValidIdentifier('undefined');\n//=> '$_undefined$'\n```\n\n## API\n\n### toValidIdentifier(string)\n\nConvert the given string to a valid JavaScript identifier.\n\nDifferent inputs will always generate unique identifiers.\n\n## Use cases\n\n- **Code Generation:** Automate safe variable naming in scripts, avoiding syntax errors from invalid characters.\n- **Compilers/Transpilers:** Essential for non-JavaScript languages compiling to JavaScript, ensuring that identifiers are compliant.\n- **Dynamic Function Names:** Generate unique and valid function names from dynamic content such as user inputs or database fields.\n- **API Wrappers:** Convert API response properties into valid JavaScript object keys for easier access.\n- **Template Processing:** Ensure template placeholders are converted to valid JavaScript identifiers when replaced with dynamic values.\n\n## Related\n\n- [is-identifier](https://github.com/sindresorhus/is-identifier) - Check if a string is a valid JavaScript identifier\n","readmeFilename":"readme.md"}