Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

babel-generate-guard-clauses

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-generate-guard-clauses - npm Package Compare versions

Comparing version 2.0.3 to 2.0.4

.travis.yml

12

package.json
{
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc