{"name":"safe-identifier","version":"0.4.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.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":"5f54bef45a308748bb29ed2b0d50f9f2b23272cc","bugs":{"url":"https://github.com/eemeli/safe-identifier/issues"},"_id":"safe-identifier@0.4.0","_nodeVersion":"13.10.1","_npmVersion":"6.14.2","dist":{"integrity":"sha512-Zor6xKXBayqkJ0ehpM+4cNzW6/rbXpcZlFpSexSOLxJuEMf+ux/DJ9s9bzUUZ13/vEGgBSGiddo9cFjFZ7QVqQ==","shasum":"34a5a1c749a84d9d7cdb60523e3d60dd6fd76d03","tarball":"http://registry-npm.ywwl.com/safe-identifier/download/safe-identifier-0.4.0.tgz","fileCount":7,"unpackedSize":6283,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeiaDGCRA9TVsSAnZWagAAX7cQAKMZE/GAJeQqGkHMJ8ef\nxskEwm6E8ACICESvU10eYf30Nyx4fZKNQ9X5LgLY8+WNCFu1JirBZ42fnJEz\nPIiedeXJ9dVxbLGK/PqfnZpDtDZYJpakFwgbepsOUf6DWzE3PJXJO0fDB+lt\nVBJVNx3EfWT88PTpEBNQHPr58ZgOig0nx/e9FpNETzHTxVSmDvaHQ/kwX/AM\nfKgHQASWluOVTCuP6ewE09k3AjuuRWVfPDOXUKJm4fc/71decv6pDovxQthn\ndK4BJmVHDb7thYsYPfyEwKmwCrFc5axu8lxjl4lH63tLzXYWTjUxsR5kNa6L\nlPfRVlIaFgY99D+IxbvcdqVPtzY/tZ0sYE9tdivubWrkku5kZ6Rd8D5azhx6\ntANTMiNBlxyx0CK2VewoDJyWw11xEWw3LG7xyk1xt0FD03/04cjLZPWmaLxr\nEA8MhCD5I2Rl72sqjUvVoQhS1ZzDCoDX9DzsXIv7NMc7smEovpSxY9qZByWa\nDBgne2ydeBhdCu6fe8ju8UNNd117NzPU+tot7oAMO4i+h7cCl9O6T4QY/xkr\nAWTvgs8+p/jRMyb6eub+Vz9icO+xb5s6r3xRFTKN64ivrojoyhg83waM0BVW\nYm5XN4iR3CiDHxONtzBiPGOL3BnY6Ucll8HOrjZ9cpr9CGo3jmwnmDlkRL/7\n6z+e\r\n=fbjk\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCqIE9lYdEHyBgCckhjqiVn3QshF5/NUpSIzRfmEY+KIQIhALlNF5TiWn49NYpFnOsh79Yavzx4hsH/mC+zvtxSh69B"}],"size":2613,"noattachment":false,"key":"/safe-identifier/-/safe-identifier-0.4.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.4.0_1586077894038_0.2160322217969377"},"_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":1586077894192,"_cnpm_publish_time":1586077894192,"dist-tags":{"latest":"0.4.2"}}