{"_id":"demolish","_rev":"267431","name":"demolish","description":"Generate a destruction method which clean's up and destroys all references on the instance","dist-tags":{"latest":"1.0.2"},"maintainers":[{"name":"3rdeden","email":""},{"name":"v1","email":""}],"time":{"modified":"2023-06-28T11:49:36.000Z","created":"2014-12-28T21:04:34.305Z","1.0.2":"2015-01-19T10:19:10.916Z","1.0.1":"2014-12-29T10:49:17.004Z","1.0.0":"2014-12-28T21:04:34.305Z"},"users":{},"author":{"name":"Arnout Kazemier"},"repository":{"type":"git","url":"https://github.com/unshiftio/demolish"},"versions":{"1.0.2":{"name":"demolish","version":"1.0.2","description":"Generate a destruction method which clean's up and destroys all references on the instance","main":"index.js","scripts":{"test":"mocha --reporter spec --ui bdd test.js","watch":"mocha --watch --reporter spec --ui bdd test.js","coverage":"istanbul cover ./node_modules/.bin/_mocha -- --reporter spec --ui bdd test.js","test-travis":"istanbul cover node_modules/.bin/_mocha --report lcovonly -- --reporter spec --ui bdd test.js"},"repository":{"type":"git","url":"https://github.com/unshiftio/demolish"},"keywords":["destroy","destruct","destroyer","destruction","demolish"],"author":{"name":"Arnout Kazemier"},"license":"MIT","bugs":{"url":"https://github.com/unshiftio/demolish/issues"},"devDependencies":{"assume":"0.0.x","istanbul":"0.3.x","mocha":"2.1.x","pre-commit":"0.0.x"},"homepage":"https://github.com/unshiftio/demolish","gitHead":"3bbb446824bba5648196a05a616d9d5057e67863","_id":"demolish@1.0.2","_shasum":"5450c0b0dac850d8d82ff738876fd3cf90be50f1","_from":".","_npmVersion":"1.4.23","_npmUser":{"name":"swaagie","email":"info@martijnswaagman.nl"},"maintainers":[{"name":"3rdeden","email":""},{"name":"v1","email":""}],"dist":{"shasum":"5450c0b0dac850d8d82ff738876fd3cf90be50f1","size":2544,"noattachment":false,"key":"/demolish/-/demolish-1.0.2.tgz","tarball":"http://name.csiicloud.com:7001/demolish/download/demolish-1.0.2.tgz"},"directories":{},"publish_time":1421662750916,"_hasShrinkwrap":false,"_cnpm_publish_time":1421662750916,"_cnpmcore_publish_time":"2021-12-15T11:15:28.037Z"},"1.0.1":{"name":"demolish","version":"1.0.1","description":"Generate a destruction method which clean's up and destroys all references on the instance","main":"index.js","scripts":{"test":"mocha --reporter spec --ui bdd test.js","watch":"mocha --watch --reporter spec --ui bdd test.js","coverage":"istanbul cover ./node_modules/.bin/_mocha -- --reporter spec --ui bdd test.js","test-travis":"istanbul cover node_modules/.bin/_mocha --report lcovonly -- --reporter spec --ui bdd test.js"},"repository":{"type":"git","url":"https://github.com/unshiftio/demolish"},"keywords":["destroy","destruct","destroyer","destruction","demolish"],"author":{"name":"Arnout Kazemier"},"license":"MIT","bugs":{"url":"https://github.com/unshiftio/demolish/issues"},"devDependencies":{"assume":"0.0.x","istanbul":"0.3.x","mocha":"2.1.x","pre-commit":"0.0.x"},"homepage":"https://github.com/unshiftio/demolish","gitHead":"aa464a245a050457ae5ce191e2139c0faaf11865","_id":"demolish@1.0.1","_shasum":"eb933f3f62adacf817758ce6e980ec40263627a8","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"V1","email":"info@3rd-Eden.com"},"maintainers":[{"name":"3rdeden","email":""},{"name":"v1","email":""}],"dist":{"shasum":"eb933f3f62adacf817758ce6e980ec40263627a8","size":3310,"noattachment":false,"key":"/demolish/-/demolish-1.0.1.tgz","tarball":"http://name.csiicloud.com:7001/demolish/download/demolish-1.0.1.tgz"},"directories":{},"publish_time":1419850157004,"_hasShrinkwrap":false,"_cnpm_publish_time":1419850157004,"_cnpmcore_publish_time":"2021-12-15T11:15:28.237Z"},"1.0.0":{"name":"demolish","version":"1.0.0","description":"Generate a destruction method which clean's up and destroys all references on the instance","main":"index.js","scripts":{"test":"mocha --reporter spec --ui bdd test.js","watch":"mocha --watch --reporter spec --ui bdd test.js","coverage":"istanbul cover ./node_modules/.bin/_mocha -- --reporter spec --ui bdd test.js","test-travis":"istanbul cover node_modules/.bin/_mocha --report lcovonly -- --reporter spec --ui bdd test.js"},"repository":{"type":"git","url":"https://github.com/unshiftio/demolish"},"keywords":["destroy","destruct","destroyer","destruction","demolish"],"author":{"name":"Arnout Kazemier"},"license":"MIT","bugs":{"url":"https://github.com/unshiftio/demolish/issues"},"devDependencies":{"assume":"0.0.x","istanbul":"0.3.x","mocha":"2.1.x","pre-commit":"0.0.x"},"homepage":"https://github.com/unshiftio/demolish","gitHead":"44c5a26d48d15f00a1691512ce0492aa22b8b922","_id":"demolish@1.0.0","_shasum":"3a9270b8edcf4f98c933b9b20bca74a9cb5f3b16","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"V1","email":"info@3rd-Eden.com"},"maintainers":[{"name":"3rdeden","email":""},{"name":"v1","email":""}],"dist":{"shasum":"3a9270b8edcf4f98c933b9b20bca74a9cb5f3b16","size":2445,"noattachment":false,"key":"/demolish/-/demolish-1.0.0.tgz","tarball":"http://name.csiicloud.com:7001/demolish/download/demolish-1.0.0.tgz"},"directories":{},"publish_time":1419800674305,"_hasShrinkwrap":false,"_cnpm_publish_time":1419800674305,"_cnpmcore_publish_time":"2021-12-15T11:15:28.479Z"}},"readme":"# demolish\n\n[![Made by unshift][made-by]](http://unshift.io)[![Version npm][version]](http://browsenpm.org/package/demolish)[![Build Status][build]](https://travis-ci.org/unshiftio/demolish)[![Dependencies][david]](https://david-dm.org/unshiftio/demolish)[![Coverage Status][cover]](https://coveralls.io/r/unshiftio/demolish?branch=master)[![IRC channel][irc]](http://webchat.freenode.net/?channels=unshift)\n\n[made-by]: https://img.shields.io/badge/made%20by-unshift-00ffcc.svg?style=flat-square\n[version]: https://img.shields.io/npm/v/demolish.svg?style=flat-square\n[build]: https://img.shields.io/travis/unshiftio/demolish/master.svg?style=flat-square\n[david]: https://img.shields.io/david/unshiftio/demolish.svg?style=flat-square\n[cover]: https://img.shields.io/coveralls/unshiftio/demolish/master.svg?style=flat-square\n[irc]: https://img.shields.io/badge/IRC-irc.freenode.net%23unshift-00a8ff.svg?style=flat-square\n\nDemolish is a small module which helps you clean, release and destroy your\ncreated instances.\n\n## Install\n\nThis module is intended for Node.js and Browserify usage and can be installed\nusing:\n\n```\nnpm install --save demolish\n```\n\n## Usage\n\nThe module is exported as a function and be required as following:\n\n```js\n'use strict';\n\nvar demolish = require('demolish');\n```\n\nThe `demolish` function returns a function which will destroy the specified\nproperties from your instance.\n\n```js\nfunction Foo() {\n  this.bar = 1;\n  this.banana = new Banana();\n}\n\nFoo.prototype.destroy = demolish('bar banana');\n```\n\nIn the example above we've created a new `destroy` method on our `Foo` class.\nOnce the method is called it will set the `bar` property to `null` and check if\n`banana` also has a `destroy` method, if so, it will call that method and set\nthe property to `null` after the execution.\n\nAfter everything is cleaned up we will emit a `destroy` event if there is an\n`emit` method available.\n\nThe `destroy` method will automatically prevent double execution by checking if\nthe first supplied property is still active on the prototype. So in the example\nabove it will check if `bar` is not `null`.\n\nBut nulling objects and destroying things you've set on an instance might not be\nenough. Sometimes you need a bit more and for those cases we have the additional\n`before` and `after` hooks. These hooks can be specified in the options:\n\n```js\nFoo.prototype.destroy = demolish('bar banana', {\n  before: 'clear',\n  after: ['removeAllListeners', function () {\n    // things\n  }]\n});\n```\n\nIn the example above you see all the supported styles. If you supply a string\nwe assume that it's a function on the prototype that needs to be executed in order\nto clean up things correctly. If you need to run multiple tasks you can supply\nan array with strings. In addition to strings we also support functions, these\nfunctions will be called with their `this` value set to the instance of the class\nwhere `destroy` works.\n\nSo in the example above the execution flow is the following:\n\n1. Check if `destroy` has already been called, if not, continue to step 2.\n2. Execute the before hook.\n3. Iterate over all properties that need to be destroyed and nulled.\n4. Emit the `destroy` event, where possible.\n5. Execute the after hook.\n\n## License\n\nMIT\n","_attachments":{},"homepage":"https://github.com/unshiftio/demolish","bugs":{"url":"https://github.com/unshiftio/demolish/issues"},"license":"MIT"}