1.2.1 • Published 3 years ago

terminable v1.2.1

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

terminable

Handle resources for graceful exit

npm.io npm.io npm.io

const Terminable = require('terminable')

const terminable = new Terminable()

const timeoutId = setTimeout(function () {
  terminable.delete(timeoutId)
  console.log('long running task')
}, 5000)

const state = terminable.add(timeoutId, function () {
  clearTimeout(timeoutId)
  setTimeout(() => console.log('clean up async'), 500)
})

process.once('SIGINT', function () {
  state.cleanup()
})

console.log('Press CTRL+C to skip 5s timeout')

Install

npm i terminable

License

Code released under the MIT License.

1.2.0

3 years ago

1.1.0

3 years ago

1.2.1

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago