{"name":"safe-identifier","version":"0.2.0","description":"Sanitize strings for use as JavaScript identifiers & property names","main":"index","sideEffects":false,"repository":{"type":"git","url":"git+https://github.com/eemeli/safe-identifier.git"},"keywords":["es3","es5","esnext","reserved","words","code","generation","identifier","property"],"author":{"name":"Eemeli Aro","email":"eemeli@gmail.com"},"license":"ISC","bugs":{"url":"https://github.com/eemeli/safe-identifier/issues"},"homepage":"https://github.com/eemeli/safe-identifier#readme","gitHead":"9b79a7a56b850e43ae64cb9b7c5c88a877cbb1be","_id":"safe-identifier@0.2.0","_nodeVersion":"12.6.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-mh2vfLJeZCvWzzhq43of651zEAVjpwoudVcexZw7sBqvpTRIEyjwIOOiPvZjOhHy806lnwbAiUo8dN4OJVl6qA==","shasum":"24bc6c4e6e86966812f6553869ba6fd3369da7fc","tarball":"http://registry-npm.ywwl.com/safe-identifier/download/safe-identifier-0.2.0.tgz","fileCount":7,"unpackedSize":6440,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdRykUCRA9TVsSAnZWagAATuIP/2zVqncEZoHBucbIj0iH\nIGmmYQ6x7/SciEFGq3oK/Abq0JtmdgJvAK1ySD9hmXOHZC+6OxRtEuONhb2S\nEgcpGOnMuvNKLO85bYxqEGeuQ44DcP97QQLZrtS55WV6H7qXq8VSudfO18B1\n92ncEwzFQCJuOmOKIqRYjLrR+EQj0614WI90Q5Mz41ISmaPahKJQLAQA/GbP\n2h18Ipydwxhtc4xW/hyoLWmx9fjFoBVyc53eiEPkgUMYZvNV+DbZsu374Qc8\nCv+tSVACPxoYrdnf7/3Xok9qbsrvmKQ7oEcJrCeiDB8S1rGgXDNScvSATPlM\nEzmlAZDwrE7oGxDX4hBbU0txQZm7r9RXbHyTjcG/LymeKkR/MSwixEkatdg/\nOXz2lDzwaNW6HGn+lPy7DGmHBbpN8gfiOFdnMgEZmgmv7mcFq5EU4FevR95+\nDeidZSfBLyxfhDKr6Pv8nauYj1/J9COOdDZ4ENSDvoNKcrqLHSj64+jzCcwe\nA00bJZsUDfEyRRUIjlgu9uRDvYh/A23uxgJ54u64KAxjequuAGKs9YT8UaAL\nmbUwfsjicQf5NqEfqy8o4KbIAYqnvOjmGF6XybKppPKA1Pv9hwZ7mMy2etoI\n/VSG3fZ9sJUV0G/TJcuo7ZNvuML5ubzi8h3D8gMwZ3sUao0S+nsHUUzUwDS3\nfPq7\r\n=iKIW\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDEgUmB9AkKl2iNPNyXduKTd0qrUZRob9RveJtUw2Mr5AiEA4cYMrliEvmkDjviZ5ItO7iVxv0e/3vyy+cQ2RtmzvgI="}],"size":2201,"noattachment":false,"key":"/safe-identifier/-/safe-identifier-0.2.0.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.2.0_1564944659544_0.01745356856304925"},"_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":1564944659694,"_cnpm_publish_time":1564944659694,"dist-tags":{"latest":"0.4.2"}}