{"name":"safe-identifier","version":"0.1.0","description":"Sanitize strings for use as JavaScript identifiers & property names","main":"index.js","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":"601022db7371532d6a3243a5e031a20f801f8a1d","_id":"safe-identifier@0.1.0","_nodeVersion":"11.9.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-DKGv8K2hu69xsbyV6loi5lFtH94egCHrf/kxhL0WKRHDL0cig1d2nmez2Qx2EAQKHIRQjmRuGsvf3rCNFErkDg==","shasum":"e31966313da5a1989a4a38604a508a387d286b5d","tarball":"http://registry-npm.ywwl.com/safe-identifier/download/safe-identifier-0.1.0.tgz","fileCount":5,"unpackedSize":4499,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcvdlHCRA9TVsSAnZWagAAkpMP/2pfBZE0oHVpNiZ/xIg4\nsukfkFsfVOBpV77+aYFRPRyD1wjF9YxDoxaEpDVZcgIKvbqlDIIUEBGxeOYV\nHwqyMp3rkUpH/WF6E2FDX5UgmTUyB2VjXV3vpjhZ3lxkS6zprYuOvbs/2I8u\nSzTpfyYO3BUCHV+9P9mU0ogHpVtQpi4sOMk3YXUIB51YuIxZ9nEFJv0aG8a6\n9fSqIRb4zF0Y92JyPSWSx939GPJXx3stgef5NbzUBsW9kE9vmlgggb7sfSgd\nCHb4iWuno4k0PB/Z5bT2cP8rLDUGgpDI4u1v3yclu95wXr+mICRt9T3QOhZn\nUf5Fw3gXH4tY9hDYBXNdCATtLICWnAiP+euisDe3Ybi/zpb8QNnp9mszRwhw\n08sE9uDrGazEWdB5I+Q+iixLpc9EQucpPNsFyO3Osss5h9oysiL4VKpXvJZE\nRIh82m1UbUGAT4DBCZ1Yx0QNQ6gmW3u/tLIWS/nYJWhkHLrJ2NyzNltVMlbV\n92X7R+Nmbwqcq16mjIUrPpKDlBl+2H1b2Ba2KwtKvX97fDBCVXv4iXDlRP2f\nH+g7crsUtvvZGwyfwowEImcL7smGf/qO/iYjxx7u4PpocVpOHCl9HN2S3bir\nE+CGjdA2NXFwTbpQcOTTRdDNCcbLPuKJ2+oe3SxL5P+L34+s7RyQ7WGydZye\nG2z/\r\n=2LG0\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHavkbod3uCU0y5Oyc+NzmWhyxaOEzN1BlN6FUR247pSAiEAwymxNzlkAyUhd+pUsBH4qIIS78rzj4WAoVIgXo+e3DM="}],"size":2086,"noattachment":false,"key":"/safe-identifier/-/safe-identifier-0.1.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.1.0_1555945798766_0.6512502406968106"},"_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":1555945798869,"_cnpm_publish_time":1555945798869,"dist-tags":{"latest":"0.4.2"}}