{"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":"http://registry-npm.ywwl.com/to-valid-identifier/download/to-valid-identifier-0.1.0.tgz","fileCount":5,"integrity":"sha512-R8KA0Ft5lk4W6eOKc1L8tJIZZofHVQHo3gEPkn3yuqISfGTHKPTlD4TIaLsycjalQplOaNw+CloEc05SDsHaxQ==","signatures":[{"sig":"MEQCIHOzzZSvhURPUb94D+9jFQx3KnobId16pXHRALe0adJdAiBXg5S2MoUogmOkbHYVUp/PTOsRY81yC6TurLdda3DMdQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":4541,"size":2172,"noattachment":false,"key":"/to-valid-identifier/-/to-valid-identifier-0.1.0.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":"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"},"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":1714933927648,"_cnpm_publish_time":1714933927648,"dist-tags":{"latest":"1.0.0"}}