{"name":"safe-identifier","version":"0.4.1","author":{"name":"Eemeli Aro","email":"eemeli@gmail.com"},"license":"ISC","description":"Sanitize strings for use as JavaScript identifiers & property names","keywords":["es3","es5","esnext","reserved","words","code","generation","identifier","property"],"main":"./index.js","type":"commonjs","exports":{".":[{"import":"./index.mjs","require":"./index.js"},"./index.js"],"./reserved":"./reserved.js"},"browser":"./index.mjs","sideEffects":false,"repository":{"type":"git","url":"git+https://github.com/eemeli/safe-identifier.git"},"homepage":"https://github.com/eemeli/safe-identifier#readme","prettier":{"semi":false,"singleQuote":true},"gitHead":"6298b814cc7dd1e805bce2d76c7ca7828ac90770","bugs":{"url":"https://github.com/eemeli/safe-identifier/issues"},"_id":"safe-identifier@0.4.1","_nodeVersion":"13.10.1","_npmVersion":"6.14.2","dist":{"integrity":"sha512-73tOz5TXsq3apuCc3vC8c9QRhhdNZGiBhHmPPjqpH4TO5oCDqk8UIsDcSs/RG6dYcFAkOOva0pqHS3u7hh7XXA==","shasum":"b6516bf72594f03142b5f914f4c01842ccb1b678","tarball":"http://registry-npm.ywwl.com/safe-identifier/download/safe-identifier-0.4.1.tgz","fileCount":7,"unpackedSize":6285,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeieJVCRA9TVsSAnZWagAAa/0P/iJmmOBSCpIbxIWpdbj6\nmlTTGMA4PVLXjcs8+vofdpNvQNzQTILGK4SZodapCHMDD8uBa/96SvDHI1Rw\nvIwJBy/t4M74zVj4rSLknol8nXWZZlAT622Mx5US+PlsVb+YpcSuE8lKRHn+\nLzS65i22mNyjr/pYCaPwmBuRa/iQA2uB09uTskKr1hXlkcYz5iiLFSE3BNR+\naQfIc05gbS9OG6b6tiDCKnan2nWV5CDyPrYX3mT0VoavHNG5H5t2L19CvB5U\nJELetQ06VNys9pHbdYKr7eAqnD86bY7B2FBwtuYhW7YqWSwgrXED+6IB5uPk\nv1TJXR78Lc9eX/vfKKT4N/T6D9IVrK8B9prnERws9wUA7vaASfy9monNP1pU\n8xvm9vsvSNVo8Iiwl9+6ZFPqqUaGrcqRUk4LsLQDywCbKZYTK++7XB2tK8+B\nG4oc7Blekox4pSY7JmdWZQGLobHfOEEZbYUMMQtZ7BmQz5WKyC9TrRQ6j6mP\nF05L5HgZ8iCVEA2/NwBUOnW8BSBhcHtO+oP4YtBYaQfk379atNJOG6uQKrEo\nU+a6WK9Ra6EZenxqdwN5Viawhavos4lWh7Rq7gEx/DVjcKeT6Ei1uS2USYMd\nRUfYSRCKn9ln3J0M0c4CmNDTZHMzInlca2Tdu/P0J79V35OzApYNkjdHuHc/\nahaw\r\n=8DiA\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDJaAhXkkFkdexsez6eXuq+rFJWByHwcrnlsWyZQf3wNgIgPp7Rlo85Jz86GP2/qhnPxVRrkXlJJWkhKId6igkO+ys="}],"size":2614,"noattachment":false,"key":"/safe-identifier/-/safe-identifier-0.4.1.tgz"},"maintainers":[{"name":"eemeli","email":"eemeli@gmail.com"}],"_npmUser":{"name":"eemeli","email":"eemeli@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/safe-identifier_0.4.1_1586094676587_0.18102585120600834"},"_hasShrinkwrap":false,"readme":"# safe-identifier\n\nSanitize strings for use as JavaScript identifiers & property names.\n\n```\nnpm install --save safe-identifier\n```\n\n```js\nimport { identifier, property } from 'safe-identifier'\n\nidentifier('Foo') === 'Foo'\nidentifier('enum') === '_enum'\nidentifier('my var', true) === 'my_var_hk17pp'\nidentifier(' my \\0var ', true) === 'my_var_1d8fi3'\n\nproperty('Foo', 'bar') === 'Foo.bar'\nproperty('Foo', 'bar\\nbar') === 'Foo[\"bar\\\\nbar\"]'\nproperty(null, 'foo') === 'foo'\nproperty(null, 'void') === '\"void\"'\n```\n\n## `identifier(key: string, unique: boolean): string`\n\nSanitize a string for use as an identifier name\n\nReplaces invalid character sequences with `_` and may add a `_` prefix if the\nresulting name would conflict with a JavaScript reserved name, covering all\nstandards from ES3 up to ES2018, along with current\n[active proposals](https://github.com/tc39/proposals).\n\nIf `unique` is true, a 32-bit hash of the `key` is appended to the result in\norder to help ensure that different inputs produce different outputs.\n\n## `property(obj: string?, key: string): string`\n\nSanitize a string for use as a property name\n\nBy default uses `obj.key` notation, falling back to `obj[\"key\"]` if the key\ncontains invalid characters or is an ECMAScript 3rd Edition reserved word\n(required for IE8 compatibility). If `obj` is empty, returns only the possibly\nquoted property key. The correctness of `obj` is not checked.\n","publish_time":1586094676732,"_cnpm_publish_time":1586094676732,"dist-tags":{"latest":"0.4.2"}}