Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Richienb/cross-exit
Gracefully terminate a script in Node.js or browsers.
https://github.com/Richienb/cross-exit
Last synced: about 2 months ago
JSON representation
Gracefully terminate a script in Node.js or browsers.
- Host: GitHub
- URL: https://github.com/Richienb/cross-exit
- Owner: Richienb
- License: mit
- Created: 2020-01-09T10:38:19.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-08-14T05:18:29.000Z (over 3 years ago)
- Last Synced: 2024-05-12T12:45:44.412Z (8 months ago)
- Language: JavaScript
- Homepage:
- Size: 443 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
- awesome-ponyfills - cross-exit - [`process.exit`](https://nodejs.org/api/process.html#process_process_exit_code) (Node.js Features)
README
# Cross Exit [![Travis CI Build Status](https://img.shields.io/travis/com/Richienb/cross-exit/master.svg?style=for-the-badge)](https://travis-ci.com/Richienb/cross-exit)
Gracefully terminate a script in Node.js or browsers. Works as a drop-in replacement for `process.exit`.
[![NPM Badge](https://nodei.co/npm/cross-exit.png)](https://npmjs.com/package/cross-exit)
## Install
```sh
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
```js
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.