when-exit
TypeScript icon, indicating that this package has built-in type declarations

2.1.2 • Public • Published

WhenExit

Execute a function right before the process, or the browser's tab, 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

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 2.1.2
    176,725
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 2.1.2
    176,725
  • 2.1.1
    18,472
  • 2.1.0
    12,183
  • 2.0.0
    585
  • 1.0.0
    126

Package Sidebar

Install

npm i when-exit

Weekly Downloads

208,091

Version

2.1.2

License

none

Unpacked Size

11.6 kB

Total Files

28

Last publish

Collaborators

  • fabiospampinato