{"name":"safe-identifier","version":"0.3.0","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","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":"acee56692d91d71e4c80299b6f3889c2d23502fd","bugs":{"url":"https://github.com/eemeli/safe-identifier/issues"},"_id":"safe-identifier@0.3.0","_nodeVersion":"12.12.0","_npmVersion":"6.11.3","dist":{"integrity":"sha512-asSqOW4W4YDfqrbBOQQ6HMZLOw91hts0EnRVCQN/HZ573OdvVgQiOsc+87uIillNq1gX+4KC2ua9abygqKf3Jg==","shasum":"da36e65c2a19c385f5d9c16896b228388aeeeaab","tarball":"http://registry-npm.ywwl.com/safe-identifier/download/safe-identifier-0.3.0.tgz","fileCount":7,"unpackedSize":7473,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJd6AsoCRA9TVsSAnZWagAAq8QP/2lyXGg9s4ubwm4JzSog\nStWIJF8lnDy/XwkI4b7W/Fne9Sddw5kYnCi/LIorZgr+n3rot3miWpzaXGFP\nKs1u2mcLt7a9oWVhdsfr+UKwTP/iJhP2KSBFIAhmvM/L+82G2vp6WAtxLhlG\npjW1LH1mu/MTRzcPsx4e31fCkAMdNNZhqO0yKuAD0SUDUFjhcsQPcJKvqwrv\n/4uoytrJTvmyHcl2B30ahT9Q6WMxL4dhb3kZmaINpaI+vRfPT73AwKQxYD5i\nmNj5dax6HRwitvl/A0R1dC//hP6XDYkC9Gtl2RTd2dNl5SH61dTRdwAV4WyE\nw+f0+cmUNFjzIfUdDzaTa5puj/BCeSAnc1BL7OkuAM97YT/bnGwf8wvvruwm\n16VCV81t/el548LfZjKnvUc5TuKZyL0JTyIHzgHpre0d+62gT3sXsVs21IjM\n4HoZY8S//UimqRz7op8rX1gU7Zbbig95V81fwUsvHKxbbjOyhXVsvZEuhHI/\nT7o+GWh6f/wkOACNIWWi2GMqgDc5sLM9q3CXJ3/j8zRCsjAOkoWmqcpuIV/a\nOEPUdS2ySmqcQP64CN5gL/yQl830rZE1ilgWh3/eTCPgCVY8VywXr0zagKjK\ns9f24KC8uDuvSg6eO8krcLsiTu7G/a7+rjk7fW6M8Y/SRwqM+Rpn0nqp76D2\ngvgp\r\n=BXWo\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGIjBOJegHJ7G7Mu+qHFMrqdMdoP4p2YlsN1oeoHLZ+DAiEA+BvSnbCXsgKYx8RPGjMYoOGRnHNRmrdwFKiYxc0+DhI="}],"size":2526,"noattachment":false,"key":"/safe-identifier/-/safe-identifier-0.3.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.3.0_1575488295980_0.19527773525358127"},"_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":1575488296117,"_cnpm_publish_time":1575488296117,"dist-tags":{"latest":"0.4.2"}}