28
index.js
@@ -1,9 +0,21 @@ | ||
'use strict' | ||
module.exports = bail | ||
function bail(err) { | ||
if (err) { | ||
throw err | ||
// prettier-ignore | ||
/** | ||
* Throw a given error. | ||
* | ||
* @type {{ | ||
* (error: Error): never | ||
* (error: null | undefined): void | ||
* (): void | ||
* }} */ | ||
export var bail = ( | ||
/** | ||
* Throw a given error. | ||
* | ||
* @param {Error?} [error] | ||
*/ | ||
function (error) { | ||
if (error) { | ||
throw error | ||
} | ||
} | ||
} | ||
) |
{ | ||
"name": "bail", | ||
"version": "1.0.5", | ||
"version": "2.0.0", | ||
"description": "Throw a given error", | ||
@@ -23,24 +23,29 @@ "license": "MIT", | ||
], | ||
"sideEffects": false, | ||
"type": "module", | ||
"main": "index.js", | ||
"types": "index.d.ts", | ||
"files": [ | ||
"index.d.ts", | ||
"index.js" | ||
], | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"browserify": "^16.0.0", | ||
"nyc": "^15.0.0", | ||
"prettier": "^1.0.0", | ||
"remark-cli": "^7.0.0", | ||
"remark-preset-wooorm": "^6.0.0", | ||
"tape": "^4.0.0", | ||
"tinyify": "^2.0.0", | ||
"xo": "^0.25.0" | ||
"@types/tape": "^4.0.0", | ||
"c8": "^7.0.0", | ||
"prettier": "^2.0.0", | ||
"remark-cli": "^9.0.0", | ||
"remark-preset-wooorm": "^8.0.0", | ||
"rimraf": "^3.0.0", | ||
"tape": "^5.0.0", | ||
"type-coverage": "^2.0.0", | ||
"typescript": "^4.0.0", | ||
"xo": "^0.38.0" | ||
}, | ||
"scripts": { | ||
"format": "remark . -qfo && prettier --write \"**/*.js\" && xo --fix", | ||
"build-bundle": "browserify index.js -s bail -o bail.js", | ||
"build-mangle": "browserify index.js -s bail -p tinyify -o bail.min.js", | ||
"build": "npm run build-bundle && npm run build-mangle", | ||
"test-api": "node test", | ||
"test-coverage": "nyc --reporter lcov tape test.js", | ||
"test": "npm run format && npm run build && npm run test-coverage" | ||
"prepack": "npm run build && npm run format", | ||
"build": "rimraf \"*.d.ts\" && tsc && type-coverage", | ||
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix", | ||
"test-api": "node test.js", | ||
"test-coverage": "c8 --check-coverage --branches 100 --functions 100 --lines 100 --statements 100 --reporter lcov node test.js", | ||
"test": "npm run build && npm run format && npm run test-coverage" | ||
}, | ||
@@ -57,6 +62,7 @@ "prettier": { | ||
"prettier": true, | ||
"esnext": false, | ||
"ignores": [ | ||
"bail.js" | ||
] | ||
"rules": { | ||
"import/no-mutable-exports": "off", | ||
"no-var": "off", | ||
"prefer-arrow-callback": "off" | ||
} | ||
}, | ||
@@ -68,8 +74,7 @@ "remarkConfig": { | ||
}, | ||
"nyc": { | ||
"check-coverage": true, | ||
"lines": 100, | ||
"functions": 100, | ||
"branches": 100 | ||
"typeCoverage": { | ||
"atLeast": 100, | ||
"detail": true, | ||
"strict": true | ||
} | ||
} |
@@ -12,2 +12,5 @@ # bail | ||
This package is ESM only: Node 12+ is needed to use it and it must be `import`ed | ||
instead of `require`d. | ||
[npm][]: | ||
@@ -22,3 +25,3 @@ | ||
```js | ||
var bail = require('bail') | ||
import {bail} from 'bail' | ||
@@ -36,2 +39,5 @@ bail() | ||
This package exports the following identifiers: `bail`. | ||
There is no default export. | ||
### `bail([err])` | ||
@@ -61,5 +67,5 @@ | ||
[build-badge]: https://img.shields.io/travis/wooorm/bail.svg | ||
[build-badge]: https://github.com/wooorm/bail/workflows/main/badge.svg | ||
[build]: https://travis-ci.org/wooorm/bail | ||
[build]: https://github.com/wooorm/bail/actions | ||
@@ -66,0 +72,0 @@ [coverage-badge]: https://img.shields.io/codecov/c/github/wooorm/bail.svg |
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
5117
18.97%5
25%34
385.71%91
7.06%0
-100%Yes
NaN10
25%