{"name":"safe-identifier","version":"0.4.2","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","./package.json":"./package.json"},"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":"d68293826d77d6e9f66270195322a146e1fe979d","bugs":{"url":"https://github.com/eemeli/safe-identifier/issues"},"_id":"safe-identifier@0.4.2","_nodeVersion":"13.10.1","_npmVersion":"6.14.2","dist":{"integrity":"sha512-6pNbSMW6OhAi9j+N8V+U715yBQsaWJ7eyEUaOrawX+isg5ZxhUlV1NipNtgaKHmFGiABwt+ZF04Ii+3Xjkg+8w==","shasum":"cf6bfca31c2897c588092d1750d30ef501d59fcb","tarball":"http://registry-npm.ywwl.com/safe-identifier/download/safe-identifier-0.4.2.tgz","fileCount":7,"unpackedSize":6325,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfL6R3CRA9TVsSAnZWagAAsuAP/2YPL4VXg+xij8K652uE\nEs2j51mA2n0A30Hd7wArDgWtHbt0HNLdp7wt8u7N29pJ+GXYDxzHr0Q73M5R\nco4draMbwNt1Pe7CRTcBl9Us73dB3fy50BmwRSKzm+Rv727uo3y9K6G3tMDf\n0jYEVSGo0NgakFD/OURC5+u75qTa8V+PqOuJ9ztNuv82je21sIr2uAytbQTn\nmRzbnQqvVg58GFciOzjCRn+lzlFgUeVNtq8W75XgE/tjXb4ReqwM2LwrmGxW\nREF73QIt4SsOfL+V8+0SY7LZcbyeVUWdpXQ+S+oIpTTjCfiUQDnyMa3AgUwW\nbWTZjlnDRhpOM2yy8nEj+/9GM/j7Ib/y9orE7Xvq7Gf5vBo1vwSKgQ91iqo5\nGCgpzzCqJCNAr5xbc3fi5Nw9fUSgTcWpWxc35PGxR3dTSKcdjsbxOqh0AX1e\nI/SUBRD1jNlYHy7oeALa2fZHnDDB1x3d35kMYWzKZ1CSd5n75B1NIuQ38Jx3\ngHMkXNpSvg4DIPDsYqMs7r000UGTXJlGcEU9+nvykxuXFfU1e9V3868xMCE0\ni6ESU5a1g9oyNQ2NA+KKhboZrpiYLjumZmMCNf+gCKTq1Umu/joiiYr3rCjh\nUPpuT4xoQCMGiWfIAkXqJepuYAhIzgGgrBJKvW6219Zg1zEmu6EuxTiFxIo4\nNrqr\r\n=eBHs\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDMKUbzB6viy5U5ysyqCfg6/mAsFwfPrSeS/H6O1Nz1QwIhAIPM9O45qJgGA4UDxs9zo+1VjXuq+DK5DGIzPdklX0Ot"}],"size":2623,"noattachment":false,"key":"/safe-identifier/-/safe-identifier-0.4.2.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.2_1596957814979_0.2751791293741128"},"_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":1596957815235,"_cnpm_publish_time":1596957815235,"dist-tags":{"latest":"0.4.2"}}