babel-generate-guard-clauses
Advanced tools
Comparing version 2.0.3 to 2.0.4
{ | ||
"name": "babel-generate-guard-clauses", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"description": "A helper to generate different guard clauses", | ||
@@ -13,3 +13,3 @@ "main": "index.js", | ||
"test": "jest", | ||
"fmt": "prettier --write **/*{.js,.json,.css}" | ||
"fmt": "prettier --write **/*.{js,json,css,md}" | ||
}, | ||
@@ -21,3 +21,3 @@ "dependencies": { | ||
"lint-staged": { | ||
"*.{js,json,css}": ["prettier --write", "git add"] | ||
"*.{js,json,css,md}": ["prettier --write", "git add"] | ||
}, | ||
@@ -40,5 +40,5 @@ "jest": { | ||
"jest": "^21.2.1", | ||
"lint-staged": "^4.2.3", | ||
"nyc": "^11.2.1", | ||
"prettier": "^1.7.4" | ||
"lint-staged": "^4.3.0", | ||
"nyc": "^11.3.0", | ||
"prettier": "^1.8.0" | ||
}, | ||
@@ -45,0 +45,0 @@ "nyc": { |
@@ -1,2 +0,2 @@ | ||
# Babel-Generate-Guard-Clause | ||
# Babel-Generate-Guard-Clause ![travis status](https://travis-ci.org/DanielMSchmidt/babel-generate-guard-clauses.svg?branch=master) [![Coverage Status](https://coveralls.io/repos/github/DanielMSchmidt/babel-generate-guard-clauses/badge.svg?branch=master)](https://coveralls.io/github/DanielMSchmidt/babel-generate-guard-clauses?branch=master) | ||
@@ -16,5 +16,8 @@ A helper to generate different guard clauses. | ||
Generated Code: | ||
```js | ||
if (typeof ponies !== "string") { | ||
throw new Error('ponies should be a string, but got ' + ponies + '(' + typeof ponies + ')'); | ||
throw new Error( | ||
"ponies should be a string, but got " + ponies + "(" + typeof ponies + ")" | ||
); | ||
} | ||
@@ -26,9 +29,18 @@ ``` | ||
```js | ||
const typeCheckAst = generateTypeCheck("number", { selector: "x" })({ name: "point" }); | ||
const typeCheckAst = generateTypeCheck("number", { selector: "x" })({ | ||
name: "point" | ||
}); | ||
``` | ||
Generated Code: | ||
```js | ||
if (typeof point.x !== "number") { | ||
throw new Error('point.x should be a number, but got ' + point.x + '(' + typeof point.x + ')'); | ||
throw new Error( | ||
"point.x should be a number, but got " + | ||
point.x + | ||
"(" + | ||
typeof point.x + | ||
")" | ||
); | ||
} | ||
@@ -42,10 +54,15 @@ ``` | ||
```js | ||
const typeCheckAst = generateIsOneOfCheck(["option1", "option2"])({ name: "argName" }); | ||
const typeCheckAst = generateIsOneOfCheck(["option1", "option2"])({ | ||
name: "argName" | ||
}); | ||
``` | ||
Generated Code: | ||
```js | ||
if (!['option1', 'option2'].some(x => x === argName)) { | ||
return new Error("argName should be one of ['option1', 'option2'], but got " + argName); | ||
if (!["option1", "option2"].some(x => x === argName)) { | ||
return new Error( | ||
"argName should be one of ['option1', 'option2'], but got " + argName | ||
); | ||
} | ||
``` | ||
``` |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
111723
8
66