{"_id":"pop-equals","_rev":"47604","name":"pop-equals","description":"Polymorphic deep equals operator","dist-tags":{"latest":"1.0.0"},"maintainers":[{"name":"kriskowal","email":""}],"time":{"modified":"2021-06-03T10:14:36.000Z","created":"2015-01-28T06:06:09.906Z","1.0.0":"2015-01-28T06:06:09.906Z"},"users":{},"author":{"name":"Kris Kowal","email":"kris@cixar.com"},"repository":{"type":"git","url":"https://github.com/kriskowal/pop-equals.git"},"versions":{"1.0.0":{"name":"pop-equals","version":"1.0.0","description":"Polymorphic deep equals operator","main":"pop-equals.js","directories":{"test":"test"},"scripts":{"test":"jasminum test"},"repository":{"type":"git","url":"https://github.com/kriskowal/pop-equals.git"},"keywords":["pop","polymorphic","operator","deep","equals"],"author":{"name":"Kris Kowal","email":"kris@cixar.com"},"license":"BSD 3-Clause","bugs":{"url":"https://github.com/kriskowal/pop-equals/issues"},"homepage":"https://github.com/kriskowal/pop-equals","devDependencies":{"jasminum":"^2.0.5"},"dependencies":{"mini-map":"^1.0.0"},"gitHead":"4c818dde83121d903dc082838b162fa51e037e1a","_id":"pop-equals@1.0.0","_shasum":"90414f8fda71a37f881d1e5e3a2e02ef0c3b7e0b","_from":".","_npmVersion":"1.4.21","_npmUser":{"name":"kriskowal","email":"kris.kowal@cixar.com"},"maintainers":[{"name":"kriskowal","email":""}],"dist":{"shasum":"90414f8fda71a37f881d1e5e3a2e02ef0c3b7e0b","size":4130,"noattachment":false,"key":"/pop-equals/-/pop-equals-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/pop-equals/download/pop-equals-1.0.0.tgz"},"publish_time":1422425169906,"_cnpm_publish_time":1422425169906,"_hasShrinkwrap":false}},"readme":"\n# Equals\n\nThis JavaScript package exports an equality operator that accepts arbitrary\nobjects and performs deep equality checks on objects and arrays, as well as\ndelegating to the equals method of other objects.\n\nAs a core principle, every value is equal to itself, including NaN, making this\nsuitable for verifying equivalent keys or values for storage or retrieval in\ncollections.\n\nA boxed value, like `new Number(10)` will always be equal to its unboxed\nequivalent, `10` in this case.\n\nThis operator can be safely used on object graphs that contain reference cycles.\nBy default, `equals` uses a `MiniMap` to recall objects it has already seen, but\nthis `memo` can be overridden.\n\n```js\nvar cycle = {};\ncycle.cycle = cycle;\nequals(cycle, cycle, null, new Map());\n```\n\nEquals accepts:\n\n-   left side value\n-   right side value\n-   equals, optional alternate equality checker for children\n-   memo, optional alternate map for memoizing already visited values. Map,\n    WeakMap, or any other memo implementing `set` or `has`. Notably, these maps\n    can be reused if the equivalent objects remain equivalent between calls.\n\n```js\nequals(10, 10)\nequals({a: 10, b: 20}}, {b: 20, a: 10})\nequals([], [])\nequals([[1, 2, 3]], [[1, 2, 3]])\n```\n\nObjects, so long as they are direct decendants of the Object prototype, are\nequivalent if they have the same keys and same respective values, but order is\nnot significant.\nValues from the left are only ever passed as left side arguments, and right only\nas right side arguments.\n\nAn array, regardless of whether it is on the left or right, is equivalent to any\nobject with the same length and owned properties, so sparse arrays with the same\nlength and owning the same entries are equivalent.\n\n```js\nequals([,[,,],], [,[,,],]);\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\nThe equals operator delegates to the equals method of either the left or right\nvalue, favoring the left, if either implements `equals`.\nIt passes the other argument, and forwards the alternate equals and memo.\nEquals methods are expected to accept and use these arguments, or at the very\nleast forward them in any recursive equality checks.\n\n## License and Copyright\n\nCopyright (c) 2014 Montage Studio Inc. and contributors.\nAll rights reserved.\nBSD 3-Clause license\n\n","_attachments":{},"homepage":"https://github.com/kriskowal/pop-equals","bugs":{"url":"https://github.com/kriskowal/pop-equals/issues"},"license":"BSD 3-Clause"}