{"_id":"on-exit-leak-free","_rev":"202321","name":"on-exit-leak-free","description":"Execute a function on exit without leaking memory, allowing all objects to be garbage collected","dist-tags":{"latest":"2.1.0"},"maintainers":[{"name":"matteo.collina","email":""}],"time":{"modified":"2023-03-21T06:27:53.000Z","created":"2021-07-07T07:22:57.929Z","2.1.0":"2022-06-22T09:27:56.120Z","2.0.0":"2022-06-22T07:55:38.120Z","1.0.0":"2022-05-31T22:20:26.685Z","0.2.0":"2021-07-23T12:33:29.009Z","0.1.0":"2021-07-07T07:22:57.929Z"},"users":{},"author":{"name":"Matteo Collina","email":"hello@matteocollina.com"},"repository":{"type":"git","url":"git+https://github.com/mcollina/on-exit-or-gc.git"},"versions":{"2.1.0":{"name":"on-exit-leak-free","version":"2.1.0","description":"Execute a function on exit without leaking memory, allowing all objects to be garbage collected","main":"index.js","scripts":{"test":"standard | snazzy && tap test/*.js"},"repository":{"type":"git","url":"git+https://github.com/mcollina/on-exit-or-gc.git"},"keywords":["weak","reference","finalization","registry","process","exit","garbage","collector"],"author":{"name":"Matteo Collina","email":"hello@matteocollina.com"},"license":"MIT","bugs":{"url":"https://github.com/mcollina/on-exit-or-gc/issues"},"homepage":"https://github.com/mcollina/on-exit-or-gc#readme","devDependencies":{"snazzy":"^9.0.0","standard":"^17.0.0","tap":"^16.0.0"},"gitHead":"223fd00d674f841b8785eeb3d7b0f8e2f2b9e003","_id":"on-exit-leak-free@2.1.0","_nodeVersion":"16.15.1","_npmVersion":"8.11.0","dist":{"shasum":"5c703c968f7e7f851885f6459bf8a8a57edc9cc4","size":3560,"noattachment":false,"key":"/on-exit-leak-free/-/on-exit-leak-free-2.1.0.tgz","tarball":"http://name.csiicloud.com:7001/on-exit-leak-free/download/on-exit-leak-free-2.1.0.tgz"},"_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"directories":{},"maintainers":[{"name":"matteo.collina","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/on-exit-leak-free_2.1.0_1655890075938_0.8722406181041178"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-06-22T09:31:18.199Z","publish_time":1655890076120,"_cnpm_publish_time":1655890076120},"2.0.0":{"name":"on-exit-leak-free","version":"2.0.0","description":"Execute a function on exit without leaking memory, allowing all objects to be garbage collected","main":"index.js","scripts":{"test":"standard | snazzy && tap test/*.js"},"repository":{"type":"git","url":"git+https://github.com/mcollina/on-exit-or-gc.git"},"keywords":["weak","reference","finalization","registry","process","exit","garbage","collector"],"author":{"name":"Matteo Collina","email":"hello@matteocollina.com"},"license":"MIT","bugs":{"url":"https://github.com/mcollina/on-exit-or-gc/issues"},"homepage":"https://github.com/mcollina/on-exit-or-gc#readme","devDependencies":{"snazzy":"^9.0.0","standard":"^17.0.0","tap":"^16.0.0"},"gitHead":"6c083e84d7007e252380098e574dceccabdf36ca","_id":"on-exit-leak-free@2.0.0","_nodeVersion":"16.15.1","_npmVersion":"8.11.0","dist":{"shasum":"c3bfe669f2c7c3a372eea38a71ec301484dabe1c","size":3282,"noattachment":false,"key":"/on-exit-leak-free/-/on-exit-leak-free-2.0.0.tgz","tarball":"http://name.csiicloud.com:7001/on-exit-leak-free/download/on-exit-leak-free-2.0.0.tgz"},"_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"directories":{},"maintainers":[{"name":"matteo.collina","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/on-exit-leak-free_2.0.0_1655884537952_0.5797627759684092"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-06-22T09:31:17.868Z","publish_time":1655884538120,"_cnpm_publish_time":1655884538120},"1.0.0":{"name":"on-exit-leak-free","version":"1.0.0","description":"Execute a function on exit without leaking memory, allowing all objects to be garbage collected","main":"index.js","scripts":{"test":"standard | snazzy && tap test/*.js"},"repository":{"type":"git","url":"git+https://github.com/mcollina/on-exit-or-gc.git"},"keywords":["weak","reference","finalization","registry","process","exit","garbage","collector"],"author":{"name":"Matteo Collina","email":"hello@matteocollina.com"},"license":"MIT","bugs":{"url":"https://github.com/mcollina/on-exit-or-gc/issues"},"homepage":"https://github.com/mcollina/on-exit-or-gc#readme","devDependencies":{"snazzy":"^9.0.0","standard":"^16.0.3","tap":"^16.0.0"},"gitHead":"a4d278b0b6a58aa7722ecc59c9c6adfddcf1bc8a","_id":"on-exit-leak-free@1.0.0","_nodeVersion":"16.14.2","_npmVersion":"8.5.0","dist":{"shasum":"4a2accb382278a266848bb1a21439e5fc3cd9881","size":3374,"noattachment":false,"key":"/on-exit-leak-free/-/on-exit-leak-free-1.0.0.tgz","tarball":"http://name.csiicloud.com:7001/on-exit-leak-free/download/on-exit-leak-free-1.0.0.tgz"},"_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"directories":{},"maintainers":[{"name":"matteo.collina","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/on-exit-leak-free_1.0.0_1654035626574_0.6903804735611352"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-05-31T22:20:29.227Z","publish_time":1654035626685,"_cnpm_publish_time":1654035626685},"0.2.0":{"name":"on-exit-leak-free","version":"0.2.0","description":"Execute a function on exit without leaking memory, allowing all objects to be garbage collected","main":"index.js","scripts":{"test":"standard | snazzy && tap test/*.js"},"repository":{"type":"git","url":"git+https://github.com/mcollina/on-exit-or-gc.git"},"keywords":["weak","reference","finalization","registry","process","exit","garbage","collector"],"author":{"name":"Matteo Collina","email":"hello@matteocollina.com"},"license":"MIT","bugs":{"url":"https://github.com/mcollina/on-exit-or-gc/issues"},"homepage":"https://github.com/mcollina/on-exit-or-gc#readme","devDependencies":{"snazzy":"^9.0.0","standard":"^16.0.3","tap":"^15.0.9"},"gitHead":"54a91f80aad1f026b9ef82114ef8bf0c3c45b600","_id":"on-exit-leak-free@0.2.0","_nodeVersion":"14.17.0","_npmVersion":"6.14.13","_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"dist":{"shasum":"b39c9e3bf7690d890f4861558b0d7b90a442d209","size":3212,"noattachment":false,"key":"/on-exit-leak-free/-/on-exit-leak-free-0.2.0.tgz","tarball":"http://name.csiicloud.com:7001/on-exit-leak-free/download/on-exit-leak-free-0.2.0.tgz"},"directories":{},"maintainers":[{"name":"matteo.collina","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/on-exit-leak-free_0.2.0_1627043608881_0.5131187509186566"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-27T17:59:15.535Z","publish_time":1627043609009,"_cnpm_publish_time":1627043609009},"0.1.0":{"name":"on-exit-leak-free","version":"0.1.0","description":"Execute a function on exit without leaking memory, allowing all objects to be garbage collected","main":"index.js","scripts":{"test":"standard | snazzy && tap test/*.js"},"repository":{"type":"git","url":"git+https://github.com/mcollina/on-exit-or-gc.git"},"keywords":["weak","reference","finalization","registry","process","exit","garbage","collector"],"author":{"name":"Matteo Collina","email":"hello@matteocollina.com"},"license":"MIT","bugs":{"url":"https://github.com/mcollina/on-exit-or-gc/issues"},"homepage":"https://github.com/mcollina/on-exit-or-gc#readme","devDependencies":{"snazzy":"^9.0.0","standard":"^16.0.3","tap":"^15.0.9"},"gitHead":"082429dd2cc5d5ca757a755d92813c2d00179f38","_id":"on-exit-leak-free@0.1.0","_nodeVersion":"14.17.2","_npmVersion":"6.14.13","dist":{"shasum":"499c139a097e46d82ae40f1802462a3d1adf6251","size":2919,"noattachment":false,"key":"/on-exit-leak-free/-/on-exit-leak-free-0.1.0.tgz","tarball":"http://name.csiicloud.com:7001/on-exit-leak-free/download/on-exit-leak-free-0.1.0.tgz"},"_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"directories":{},"maintainers":[{"name":"matteo.collina","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/on-exit-leak-free_0.1.0_1625642577785_0.1927204270556615"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-27T17:59:15.441Z","publish_time":1625642577929,"_cnpm_publish_time":1625642577929}},"readme":"# on-exit-leak-free\n\nThis module helps dispose of an object gracefully when the Node.js process exits.\nIt executes a function with a given parameter\non [`'exit'`](https://nodejs.org/api/process.html#event-exit) without leaking memory,\ncleaning things up appropriately if the object is garbage collected.\n\nRequires `WeakRef` and `FinalizationRegistry`, i.e. use Node v14+.\n\n## Install\n\n```bash\nnpm i on-exit-leak-free\n```\n\n## Example\n\n```js\n'use strict'\n\nconst { register, unregister } = require('on-exit-leak-free')\nconst assert = require('assert')\n\nfunction setup () {\n  // This object can be safely garbage collected,\n  // and the resulting shutdown function will not be called.\n  // There are no leaks.\n  const obj = { foo: 'bar' }\n  register(obj, shutdown)\n  // use registerBeforeExit(obj, shutdown) to execute the function only\n  // on beforeExit\n  // call unregister(obj) to remove\n}\n\nlet shutdownCalled = false\n\n// Please make sure that the function passed to register()\n// does not create a closure around unnecessary objects.\nfunction shutdown (obj, eventName) {\n  console.log(eventName) // beforeExit\n  shutdownCalled = true\n  assert.strictEqual(obj.foo, 'bar')\n}\n\nsetup()\n\nprocess.on('exit', function () {\n  assert.strictEqual(shutdownCalled, true)\n})\n```\n\n## License\n\nMIT\n","_attachments":{},"homepage":"https://github.com/mcollina/on-exit-or-gc#readme","bugs":{"url":"https://github.com/mcollina/on-exit-or-gc/issues"},"license":"MIT"}