Home

Awesome

Cross Exit Travis CI Build Status

Gracefully terminate a script in Node.js or browsers. Works as a drop-in replacement for process.exit.

NPM Badge

Install

npm install cross-exit

Strategy

In Node.js, cross-exit uses process.exit() and in browsers, window.onerror is temporarily set to hide a termination error which is then thrown.

Usage

const exit = require("cross-exit");

console.log("This message is logged.");
exit();
console.log("This message isn't logged.");

API

crossExit(code?)

code

Type: number
Default: 0

The exit code.