Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

cross-exit

Richienb21MIT1.0.0TypeScript support: included

Gracefully terminate a script in Node.js or browsers.

exit, process, browser, error, terminate, graceful, silent, break, scope, catch, window, document, node, replacement, ponyfill

readme

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.