{"_id":"pop-hash","_rev":"48061","name":"pop-hash","description":"A hash function for arbitrary objects","dist-tags":{"latest":"1.0.1"},"maintainers":[{"name":"kriskowal","email":""}],"time":{"modified":"2021-06-03T10:14:46.000Z","created":"2015-01-27T07:36:16.350Z","1.0.1":"2015-08-24T00:31:44.773Z","1.0.0":"2015-01-27T07:36:16.350Z"},"users":{},"author":{"name":"Kris Kowal","email":"kris@cixar.com"},"repository":{"type":"git","url":"git+https://github.com/kriskowal/pop-hash.git"},"versions":{"1.0.1":{"name":"pop-hash","version":"1.0.1","description":"A hash function for arbitrary objects","main":"pop-hash.js","repository":{"type":"git","url":"git+https://github.com/kriskowal/pop-hash.git"},"keywords":["hash","polymorphic","operator"],"author":{"name":"Kris Kowal","email":"kris@cixar.com"},"license":"MIT","bugs":{"url":"https://github.com/kriskowal/pop-hash/issues"},"homepage":"https://github.com/kriskowal/pop-hash","dependencies":{"weak-map":"^1.0.5"},"gitHead":"26b90512885030905a5df3978b4eded6f0d8ab42","_id":"pop-hash@1.0.1","scripts":{},"_shasum":"bcd69454bd2f99ded20b5fc8a2b93d6b5fab44cc","_from":".","_npmVersion":"2.10.1","_nodeVersion":"0.10.38","_npmUser":{"name":"kriskowal","email":"kris.kowal@cixar.com"},"dist":{"shasum":"bcd69454bd2f99ded20b5fc8a2b93d6b5fab44cc","size":1670,"noattachment":false,"key":"/pop-hash/-/pop-hash-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/pop-hash/download/pop-hash-1.0.1.tgz"},"maintainers":[{"name":"kriskowal","email":""}],"directories":{},"publish_time":1440376304773,"_cnpm_publish_time":1440376304773,"_hasShrinkwrap":false},"1.0.0":{"name":"pop-hash","version":"1.0.0","description":"A hash function for arbitrary objects","main":"pop-hash.js","browser":{"./pop-hash":"./browser-pop-hash.js"},"repository":{"type":"git","url":"https://github.com/kriskowal/pop-hash.git"},"keywords":["hash","polymorphic","operator"],"author":{"name":"Kris Kowal","email":"kris@cixar.com"},"license":"MIT","bugs":{"url":"https://github.com/kriskowal/pop-hash/issues"},"homepage":"https://github.com/kriskowal/pop-hash","dependencies":{"objhash":"^1.0.5","weak-map":"^1.0.5"},"gitHead":"4b6763f97f483b1dac88205946924605b974cddd","_id":"pop-hash@1.0.0","scripts":{},"_shasum":"4db03d1524ae62418a56e6ea6f50c1c54c0ba72f","_from":".","_npmVersion":"1.4.21","_npmUser":{"name":"kriskowal","email":"kris.kowal@cixar.com"},"maintainers":[{"name":"kriskowal","email":""}],"dist":{"shasum":"4db03d1524ae62418a56e6ea6f50c1c54c0ba72f","size":1660,"noattachment":false,"key":"/pop-hash/-/pop-hash-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/pop-hash/download/pop-hash-1.0.0.tgz"},"directories":{},"publish_time":1422344176350,"_cnpm_publish_time":1422344176350,"_hasShrinkwrap":false}},"readme":"\n## Hash\n\nHash is a function that will consistently return the same, almost unique value\nfor any given value, particularly objects.\nHashing is suitable for grouping objects into buckets with a low probability of\nmultiple non-identical values sharing the same bucket.\n\n```js\nvar hash = require(\"pop-hash\");\nhash([])\nhash({})\nhash(1)\n```\n\n## Polymorphic operator\n\nA well-planned system of objects is beautiful: a system where every meaningful\nmethod for an object has been anticipated in the design.\nInevitably, another layer of architecture introduces a new concept and with it\nthe temptation to monkey-patch, dunk-punch, or otherwise cover-up the omission.\nBut reaching backward in time, up through the layers of architecture doesn't\nalways compose well, when different levels introduce concepts of the same name\nbut distinct behavior.\n\nA polymorphic operator is a function that accepts as its first argument an\nobject and varies its behavior depending on its type.\nSuch an operator has the benefit of covering for the types from higher layers of\narchitecture, but defers to the eponymous method name of types yet to be\ndefined.\n\n```js\nhash({\n    hash: function () {\n        return JSON.stringify(this);\n    }\n})\n```\n\n## Implementation\n\nThe implementation of this object identity hash varies between browsers and\nNode.js using the \"browser\" configuration in package.json, which is respected by\n[Browserify][] and similar tools, particularly [Mr][].\n\n[Browserify]: https://github.com/substack/node-browserify\n[Mr]: https://github.com/montagejs/mr\n\nThe implementation uses a WeakMap or a WeakMap shim to assign and recall\na randomly generated number to every object it encounters.\nHash methods in general may return either strings or numbers, since either is\nsuitable for use as a key in a plain object.\nNon object values pass through hash.\n\nThe Node.js implementation once took advantage of Aleksey Smolenchuck's\n`objhash` module, which uses V8's own internal object hash function, but\nbut the binary dependency prooved a burden to maintain.\n","_attachments":{},"homepage":"https://github.com/kriskowal/pop-hash","bugs":{"url":"https://github.com/kriskowal/pop-hash/issues"},"license":"MIT"}