{"_id":"pop-clear","_rev":"46905","name":"pop-clear","description":"Clears arrays, objects, and instances that implement the clear method.","dist-tags":{"latest":"1.0.0"},"maintainers":[{"name":"kriskowal","email":""}],"time":{"modified":"2021-06-03T10:14:24.000Z","created":"2015-03-07T21:37:55.067Z","1.0.0":"2015-03-07T21:37:55.067Z"},"users":{},"author":{"name":"Kris Kowal","email":"kris@cixar.com"},"repository":{"type":"git","url":"https://github.com/kriskowal/pop-clear.git"},"versions":{"1.0.0":{"name":"pop-clear","version":"1.0.0","description":"Clears arrays, objects, and instances that implement the clear method.","main":"index.js","directories":{"test":"test"},"scripts":{"test":"jasminum test"},"repository":{"type":"git","url":"https://github.com/kriskowal/pop-clear.git"},"keywords":["polymorphic","operator","pop","clear"],"author":{"name":"Kris Kowal","email":"kris@cixar.com"},"license":"MIT","bugs":{"url":"https://github.com/kriskowal/pop-clear/issues"},"homepage":"https://github.com/kriskowal/pop-clear","devDependencies":{"jasminum":"0.0.4"},"gitHead":"b348d41f77f0784ab4268d1c2679b085d86e5ac5","_id":"pop-clear@1.0.0","_shasum":"fc8164fc85f89f288f23b936b6801ea822ae4586","_from":".","_npmVersion":"1.4.21","_npmUser":{"name":"kriskowal","email":"kris.kowal@cixar.com"},"maintainers":[{"name":"kriskowal","email":""}],"dist":{"shasum":"fc8164fc85f89f288f23b936b6801ea822ae4586","size":1809,"noattachment":false,"key":"/pop-clear/-/pop-clear-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/pop-clear/download/pop-clear-1.0.0.tgz"},"publish_time":1425764275067,"_cnpm_publish_time":1425764275067,"_hasShrinkwrap":false}},"readme":"\n# Clear\n\nThis JavaScript package exports a clear operator that accepts an array, object,\nor any other object that implements the clear method.\nFor objects, the clear method deletes all enumerable properties.\n\n```\n$ npm install --save pop-clear\n```\n\n```js\nvar clear = require(\"pop-clear\");\n\nvar array = [1, 2, 3];\nclear(array);\nexpect(array).toEqual([]);\n\nvar object = {a: 10, b: 20};\nclear(object);\nexpect(object).toEqual({});\n\nvar instance = {\n    clear: function () {\n        throw new TypeError(\"Can't clear\");\n    }\n};\nexpect(function () {\n    clear(instance);\n}).toThrow();\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 clear operator delegates to the clear method of the given object if it is\nimplemented.\nThis is particularly useful for cases where the object may be an array or an\nobservable array, for which the `clear` method has been overridden to dispatch\nranged content changes.\n\n## License and Copyright\n\nCopyright (c) 2015 Kristopher Michael Kowal and contributors.\nAll rights reserved.\nMIT License\n\n","_attachments":{},"homepage":"https://github.com/kriskowal/pop-clear","bugs":{"url":"https://github.com/kriskowal/pop-clear/issues"},"license":"MIT"}