{"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":"http://registry-npm.ywwl.com/to-valid-identifier/download/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,"size":2169,"noattachment":false,"key":"/to-valid-identifier/-/to-valid-identifier-0.1.1.tgz"},"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"},"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":1716892630914,"_cnpm_publish_time":1716892630914,"dist-tags":{"latest":"1.0.0"}}