CoolFace
Apppublic

AK-21/Graphite-Industrial-Intelligence

sourceHugging Faceupdated 3mo agoView on Hugging Face
0likes
readme.md148 linesDownload Raw Back to bail
1# bail2 3[![Build][build-badge]][build]4[![Coverage][coverage-badge]][coverage]5[![Downloads][downloads-badge]][downloads]6[![Size][size-badge]][size]7 8Throw if given an error.9 10## Contents11 12*   [What is this?](#what-is-this)13*   [When should I use this?](#when-should-i-use-this)14*   [Install](#install)15*   [Use](#use)16*   [API](#api)17    *   [`bail(err?)`](#bailerr)18*   [Types](#types)19*   [Compatibility](#compatibility)20*   [Security](#security)21*   [Related](#related)22*   [Contribute](#contribute)23*   [License](#license)24 25## What is this?26 27This package throws a given error.28 29## When should I use this?30 31Use this package if you’re building some scripts that might theoretically get32errors but frequently don’t and you keep writing `if (error) throw error` over33and over again and you’re just really done with that.34 35## Install36 37This package is [ESM only][esm].38In Node.js (version 12.20+, 14.14+, or 16.0+), install with [npm][]:39 40```sh41npm install bail42```43 44In Deno with [Skypack][]:45 46```js47import {bail} from 'https://cdn.skypack.dev/bail@2?dts'48```49 50In browsers with [Skypack][]:51 52```html53<script type="module">54  import {bail} from 'https://cdn.skypack.dev/bail@2?min'55</script>56```57 58## Use59 60```js61import {bail} from 'bail'62 63bail()64 65bail(new Error('failure'))66// Error: failure67//     at repl:1:668//     at REPLServer.defaultEval (repl.js:154:27)69//     …70```71 72## API73 74This package exports the following identifier: `bail`.75There is no default export.76 77### `bail(err?)`78 79Throw a given error (`Error?`).80 81## Types82 83This package is fully typed with [TypeScript][].84There are no extra exported types.85 86## Compatibility87 88This package is at least compatible with all maintained versions of Node.js.89As of now, that is Node.js 12.20+, 14.14+, and 16.0+.90It also works in Deno and modern browsers.91 92## Security93 94This package is safe.95 96## Related97 98*   [`noop`][noop]99*   [`noop2`][noop2]100*   [`noop3`][noop3]101 102## Contribute103 104Yes please!105See [How to Contribute to Open Source][contribute].106 107## License108 109[MIT][license] © [Titus Wormer][author]110 111<!-- Definitions -->112 113[build-badge]: https://github.com/wooorm/bail/workflows/main/badge.svg114 115[build]: https://github.com/wooorm/bail/actions116 117[coverage-badge]: https://img.shields.io/codecov/c/github/wooorm/bail.svg118 119[coverage]: https://codecov.io/github/wooorm/bail120 121[downloads-badge]: https://img.shields.io/npm/dm/bail.svg122 123[downloads]: https://www.npmjs.com/package/bail124 125[size-badge]: https://img.shields.io/bundlephobia/minzip/bail.svg126 127[size]: https://bundlephobia.com/result?p=bail128 129[npm]: https://docs.npmjs.com/cli/install130 131[skypack]: https://www.skypack.dev132 133[license]: license134 135[author]: https://wooorm.com136 137[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c138 139[typescript]: https://www.typescriptlang.org140 141[contribute]: https://opensource.guide/how-to-contribute/142 143[noop]: https://www.npmjs.com/package/noop144 145[noop2]: https://www.npmjs.com/package/noop2146 147[noop3]: https://www.npmjs.com/package/noop3148