{"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":"http://registry-npm.ywwl.com/to-valid-identifier/download/to-valid-identifier-1.0.0.tgz","fileCount":5,"unpackedSize":4621,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIEwpt7ciILXsyEO2OP7W3/ohyzBusrHJxxMUSnyUer7MAiAE0Nz6lMDW+9nHtST7jzfO+Eu5975w+t8srm+kLfdxMw=="}],"size":2197,"noattachment":false,"key":"/to-valid-identifier/-/to-valid-identifier-1.0.0.tgz"},"_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,"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","publish_time":1760495018881,"_cnpm_publish_time":1760495018881,"dist-tags":{"latest":"1.0.0"}}