{"_id":"@axaptional/object-id","_rev":"2-eb7d8b3b4482ed4f391f50c607a54d4c","name":"@axaptional/object-id","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@axaptional/object-id","version":"1.0.0","description":"A simple utility function that creates and returns incremental object IDs","main":"dist/object-id.js","types":"dist/object-id.d.ts","scripts":{"test":"mocha","build":"webpack","lint":"tslint -p tsconfig.json","lint:fix":"tslint -p tsconfig.json --fix","prepare":"npm run build","prepublishOnly":"npm test && npm run lint","preversion":"npm run lint","version":"git add -A src","postversion":"git push && git push --tags"},"directories":{"lib":"dist"},"repository":{"type":"git","url":"git+https://github.com/axaptional/object-id.git"},"keywords":["incremental","object","id","oid","weak","map","weakmap"],"author":{"name":"André Mategka","email":"12amdeveloper@gmail.com"},"license":"Unlicense","bugs":{"url":"https://github.com/axaptional/object-id/issues"},"homepage":"https://github.com/axaptional/object-id","devDependencies":{"mocha":"^6.0.2","terser-webpack-plugin":"^1.2.3","ts-declaration-webpack-plugin":"^1.1.1","ts-loader":"^5.3.3","tslint":"^5.13.0","tslint-config-standard":"^8.0.1","typescript":"^3.3.3333","webpack":"^4.29.5","webpack-cli":"^3.2.3"},"gitHead":"1e7c533af6ea8b5a4f048c87ed6ce6c1505220c9","_id":"@axaptional/object-id@1.0.0","_npmVersion":"6.5.0-next.0","_nodeVersion":"11.6.0","_npmUser":{"name":"am307","email":"12amdeveloper@gmail.com"},"dist":{"integrity":"sha512-5IlJJc8RN9z7HtC8ljOKpdtW01dvKE58qfQWDXxfJOcaMXC1Gg+1VA42KzkAWwI8+q2Y9FjG7mNA2uUB8I1d5Q==","shasum":"9b0bab38ad6d7a94b00cfbd6f0410e4d1833e3dd","tarball":"https://registry.npmjs.org/@axaptional/object-id/-/object-id-1.0.0.tgz","fileCount":6,"unpackedSize":8340,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJce0WFCRA9TVsSAnZWagAAdPsP/iSqw92bfo8m+x8q3b/a\nETC9LJCKUN4PLn35TRygOy0hvKO2qDyD1H4W9xdXfW2FlKUS7ENRB33tOZfx\nrnkNyWyQjLQ5CtUVg6XTk+G9GwqxqRG586YXCenpyoxTbscYHCrrApMi6SZC\nUVwuqn5+yurbRgMyx2Cvx1NVBwlVf+9137QvT60vMmkExzPZvI1JlbNJm3r7\nbxvgv6iidWPy4nQDBN5nh4L18Lh5Nbmx1FTXZYIYnD0JQpLa6UuSWqDtjxbi\nbzjIZfPL6IwrVThg0SUdAeYzAR1djmr5PoFavaWtRb4VIQ5IBQVa8pLSu3ET\n+/NFMVz6LVCfc6dmYbr6kTE4A2+BF7yo70dfwyyqqAYFjpt3zSelBjvHPg1S\n8VAK4G1Gey5A20PH/G2XdJqF+mkW/MSbR0lgZvv0cu626RKE8jPE00clOinX\n67ins6eEE5gHBN1JcN62CdIi1Ft7HQOB6OhLRr6fWB8QZfZnYrhcQxh0sfsE\n1lg6uZaVWmGJPTARQJE+XmAXAFIYV8tEqMP3I+oiziAJ1JeQITZ7PjmOwFF0\nHN0jc3vY9IjqZ2weVRkTqOP5jA7jgHnzlb/pXBjHqM9ICOEMrCetSypdYCYP\nIGFBNwoTHf/nBwYbHjx0G2fRptmYKbvYi18dHwQK5ECo7vhf81GmZUPxa2eZ\neVUF\r\n=j3sh\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCMNiftaqeUwl28y6JaojwdA8pB4IOa7Jss2PQHCgSIkwIgRMLaoSHtZ3iEePF47dUlKZ7BRDn25KsVUn1ur7CTEko="}]},"maintainers":[{"name":"am307","email":"12amdeveloper@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/object-id_1.0.0_1551582595991_0.8436355679168701"},"_hasShrinkwrap":false},"1.0.1":{"name":"@axaptional/object-id","version":"1.0.1","description":"A simple utility function that creates and returns incremental object IDs","main":"dist/object-id.js","types":"dist/object-id.d.ts","scripts":{"test":"mocha","build":"webpack","lint":"tslint -p tsconfig.json","lint:fix":"tslint -p tsconfig.json --fix","prepare":"npm run build","prepublishOnly":"npm test && npm run lint","preversion":"npm run lint","version":"git add -A src","postversion":"git push && git push --tags"},"directories":{"lib":"dist"},"repository":{"type":"git","url":"git+https://github.com/axaptional/object-id.git"},"keywords":["incremental","object","id","oid","weak","map","weakmap"],"author":{"name":"André Mategka","email":"12amdeveloper@gmail.com"},"license":"Unlicense","bugs":{"url":"https://github.com/axaptional/object-id/issues"},"homepage":"https://github.com/axaptional/object-id","devDependencies":{"mocha":"^6.1.4","terser-webpack-plugin":"^1.2.3","ts-declaration-webpack-plugin":"^1.1.1","ts-loader":"^5.3.3","tslint":"^5.18.0","tslint-config-standard":"^8.0.1","typescript":"^3.3.3333","webpack":"^4.29.5","webpack-cli":"^3.2.3"},"gitHead":"edc28d8a02005126d0bc7b7e086c09c901abd258","_id":"@axaptional/object-id@1.0.1","_npmVersion":"6.5.0-next.0","_nodeVersion":"11.6.0","_npmUser":{"name":"am307","email":"12amdeveloper@gmail.com"},"dist":{"integrity":"sha512-NGnwbbTvP1hM4de388R6WOTYXWuTDsb6Z8/b1lUzibYrOu5Hz9U55K8Cx6Lw6EdMESseoao8c5CBpQ8U/wIBwA==","shasum":"ee68fd234f33f4ab4fbb2cfcd8efd44bc12fcb25","tarball":"https://registry.npmjs.org/@axaptional/object-id/-/object-id-1.0.1.tgz","fileCount":6,"unpackedSize":8474,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdH+yVCRA9TVsSAnZWagAAhQkP/3lOHZGHZ9Z0GxkQSG2Z\nT9U5LpgsKrdw5yvpyYOw2YG3kyLUcIeSlA3MV8Mf/R8jVMJHsCuhF6tk9a94\nwiGWId1B6FDDEAJjfD6nKVgCslBg5EQoXc9KI2t0dJxoCOb+sNMgFfqTjg2V\nC6er4ZVGhYZd8yQ3Cc1ZKMuEgE/jaf/RWgWlM86yzYXRCuYVfihB1aD1MqHW\ni5Afr/U9mFD3vuPlv1y7JHA+lWCHKD/e43P3a8z2yP9y2jKCoJOPVO2JtKag\nxM7EFi4nDEjiyLH/zu2H4DJvB3oVITvtR5XwQoniweEyyxhQ78hAQg2RoC0v\nh7PEqNcMbHfN3GsbELIojcJ7l+mMn9bP1/rQ8WVu2vsOQc+PxEZX6BR+oFxV\nTj+jMwzsdBxd3EL4YB9dCTaL4iFBYSMbj8VahcE7q0ZlWOUO62zol/8gVNLd\nUyQYSCIRBfyMv1UPbkU49CJnA+XyCESj0UwNRUKFcPyyq1km5V95VUrXZBhn\n09DIql8Qk+bC6dxpnGrP3rdz8nBWdltDlqjx3hI9LaOz4iUwxBW2UWmV+GM4\nrswWCGbgSZF64KbwvIU7lAqU+cSsr1LTVF6k5f6Zs4XxiKzrZCCWw1QAcs96\nY1sncKzZ+vYrMS+22S40Z/OpWwique7KVGslHFCG2ZmhUXVsDbTnIYr4If75\nYab0\r\n=LAeY\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCV/9b/DFuTItXHmMy5AUrpz6GM7RibBfNupGlcc9ox6QIhAMfA5dP2n2iMqt8D05gqyvxo0lN7y2qjY5OwVTTNAF4s"}]},"maintainers":[{"name":"am307","email":"12amdeveloper@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/object-id_1.0.1_1562373268623_0.5656018878426934"},"_hasShrinkwrap":false}},"time":{"created":"2019-03-03T03:09:55.820Z","1.0.0":"2019-03-03T03:09:56.107Z","modified":"2022-04-04T17:08:27.939Z","1.0.1":"2019-07-06T00:34:28.732Z"},"maintainers":[{"name":"am307","email":"12amdeveloper@gmail.com"}],"description":"A simple utility function that creates and returns incremental object IDs","homepage":"https://github.com/axaptional/object-id","keywords":["incremental","object","id","oid","weak","map","weakmap"],"repository":{"type":"git","url":"git+https://github.com/axaptional/object-id.git"},"author":{"name":"André Mategka","email":"12amdeveloper@gmail.com"},"bugs":{"url":"https://github.com/axaptional/object-id/issues"},"license":"Unlicense","readme":"# object-id\r\nA simple utility function that creates and returns incremental object IDs\r\n\r\n## Installation\r\n\r\nUse `npm` to install [`@axaptional/object-id`][NPM]:\r\n\r\n```bash\r\n$ npm install @axaptional/object-id\r\n```\r\n\r\n## Usage\r\n\r\nThis package is actually just a tiny wrapper around a WeakMap.\r\n\r\nTherefore:\r\n- only objects may be mapped to an ID.\r\n- attempting to retrieve the ID of a primitive value will raise a TypeError.\r\n  - (primitives are Boolean, Null, Undefined, Number, String and Symbol)\r\n- IDs are equal when their objects are strictly equal (`===`).\r\n\r\n### Import\r\n\r\nImport the `id` object from this package:\r\n\r\n```js\r\n// ES2015+ syntax\r\nimport { id } from '@axaptional/object-id';\r\n// CommonJS syntax (Node)\r\nconst { id } = require('@axaptional/object-id');\r\n```\r\n\r\n### `id(<object>)`\r\n\r\nTo retrieve an ID for a given object, use `id(<object>)` or `id.id(<object>)`:\r\n\r\n```js\r\nconst square = x => x * x;\r\nconst idBefore = id(square);\r\nsquare.squaresNumbers = true;\r\nconst idAfter = id(square);\r\nconsole.log(idBefore === idAfter); // prints \"true\"\r\n```\r\n\r\nThe second variant can come in handy if you already have an \"id\" module\r\nimported and do not want to add a suffix to the alias:\r\n```js\r\nimport { id as Axaptional } from '@axaptional/object-id';\r\nAxaptional.id({});\r\n```\r\n\r\n### `has(<object>, <id>)`\r\n\r\nTo check an object against an ID, use `id.has(<object>, <id>)`:\r\n\r\n```js\r\nlet square = x => x * x;\r\nconst squareId = id(square);\r\nsquare = x => Math.pow(x, 2);\r\nconsole.log(id.has(square, squareId)); // prints \"false\"\r\n```\r\n\r\n### `clear()`\r\n\r\nTo clear the object ID store, use `id.clear()`:\r\n\r\n```js\r\nconst square = x => x * x;\r\nconst squareId = id(square);\r\nid.clear();\r\nconsole.log(id.has(square, squareId)); // prints \"false\"\r\n```\r\n\r\nIt is guaranteed that identifying an object both before and after a call to\r\n`clear()` will yield different IDs as long as you do not attempt to identify\r\nmore objects than `Number.MAX_SAFE_INTEGER` in total.\r\nIn other words, calling `clear()` does not reset the ID counter.\r\n\r\n### Sidenote\r\n\r\nOf course, if you want to check if two objects have the same ID,\r\nyou do not need to rely on `id` at all and can instead simply compare\r\nthe two objects with `===`.\r\nStrictly unequal objects have different IDs,\r\nwhile strictly equal objects always have the same ID.\r\n\r\n## License\r\n\r\nThis package is available under the [Unlicense][LICENSE].\r\n\r\n<!-- References -->\r\n[NPM]: https://www.npmjs.com/package/@axaptional/object-id\r\n[LICENSE]: https://github.com/axaptional/object-id/blob/master/LICENSE\r\n","readmeFilename":"README.md"}