when-exit

Execute a function right before the process is about to exit.

Usage no npm install needed!

<script type="module">
  import whenExit from 'https://cdn.skypack.dev/when-exit';
</script>

README

When Exit

Execute a function right before the process is about to exit.

Install

npm install --save when-exit

Usage

import whenExit from 'when-exit';

onExit ( () => {
  console.log ( 'Callback 1' );
});

onExit ( () => {
  console.log ( 'Callback 2' );
});

const disposer = onExit ( () => {
  console.log ( 'Callback 3' );
});

disposer ();

process.exit (); // Callback 1 and 2 are called before exiting

License

MIT © Fabio Spampinato