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

babel-plugin-transform-isnil

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-transform-isnil - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

2

lib/index.js

@@ -55,3 +55,3 @@ 'use strict';

/* eslint no-void: 0 */
path.replaceWithSourceString('(' + name + ' === null || ' + name + ' === void 0)');
path.replaceWithSourceString('\n (((typeof window === \'undefined\' ? global : window).__TMP_VAL__ = ' + name + ') || true) &&\n ((typeof (typeof window === \'undefined\' ? global : window).__TMP_VAL__)) === \'undefined\' ||\n (typeof window === \'undefined\' ? global : window).__TMP_VAL__ === null\n ');
})();

@@ -58,0 +58,0 @@ }

{
"name": "babel-plugin-transform-isnil",
"version": "0.0.5",
"version": "0.0.6",
"description": "replace the comparing of null or undefined with isNil",

@@ -5,0 +5,0 @@ "main": "lib",

@@ -147,3 +147,3 @@ # babel-plugin-transform-isNil

* Node v5.2.0
* Node v6.2.0
* npm v3.7.2

@@ -150,0 +150,0 @@

@@ -51,3 +51,7 @@ import flatten from 'flat'

/* eslint no-void: 0 */
path.replaceWithSourceString(`(${name} === null || ${name} === void 0)`)
path.replaceWithSourceString(`
(((typeof window === 'undefined' ? global : window).__TMP_VAL__ = ${name}) || true) &&
((typeof (typeof window === 'undefined' ? global : window).__TMP_VAL__)) === 'undefined' ||
(typeof window === 'undefined' ? global : window).__TMP_VAL__ === null
`)
}

@@ -54,0 +58,0 @@ }

@@ -19,3 +19,3 @@ import test from 'ava-spec'

before: 'hoge.isNil',
after: '"use strict";\n\nhoge === null || hoge === void 0;'
after: `"use strict";\n\n(((typeof window === 'undefined' ? global : window).__TMP_VAL__ = hoge) || true) && typeof (typeof window === 'undefined' ? global : window).__TMP_VAL__ === 'undefined' || (typeof window === 'undefined' ? global : window).__TMP_VAL__ === null;`
},

@@ -25,10 +25,5 @@ {

before: '!hoge.isNil',
after: '"use strict";\n\n!(hoge === null || hoge === void 0);'
after: `"use strict";\n\n!((((typeof window === 'undefined' ? global : window).__TMP_VAL__ = hoge) || true) && typeof (typeof window === 'undefined' ? global : window).__TMP_VAL__ === 'undefined' || (typeof window === 'undefined' ? global : window).__TMP_VAL__ === null);`
},
{
description: 'expect isNil replace to `=== null || === void 0`',
before: 'class Hoge { constructor(hoge) { if (this.hoge.isNil) { this.hoge = hoge; } } }',
after: '"use strict";\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }\n\nvar Hoge = function Hoge(hoge) {\n _classCallCheck(this, Hoge);\n\n if (this.hoge === null || this.hoge === void 0) {\n this.hoge = hoge;\n }\n};'
},
{
description: 'expect isNil() dont replace',

@@ -39,10 +34,10 @@ before: 'R.isNil()',

{
description: '',
description: 'function call test 1',
before: 'foo.bar().isNil',
after: '"use strict";\n\nfoo.bar() === null || foo.bar() === void 0;'
after: `"use strict";\n\n(((typeof window === 'undefined' ? global : window).__TMP_VAL__ = foo.bar()) || true) && typeof (typeof window === 'undefined' ? global : window).__TMP_VAL__ === 'undefined' || (typeof window === 'undefined' ? global : window).__TMP_VAL__ === null;`
},
{
description: '',
description: 'function call test 2',
before: 'foo.bar(hoge).isNil',
after: '"use strict";\n\nfoo.bar(hoge) === null || foo.bar(hoge) === void 0;'
after: `"use strict";\n\n(((typeof window === 'undefined' ? global : window).__TMP_VAL__ = foo.bar(hoge)) || true) && typeof (typeof window === 'undefined' ? global : window).__TMP_VAL__ === 'undefined' || (typeof window === 'undefined' ? global : window).__TMP_VAL__ === null;`
},

@@ -52,3 +47,3 @@ {

before: 'foo[0].isNil',
after: '"use strict";\n\nfoo[0] === null || foo[0] === void 0;'
after: `"use strict";\n\n(((typeof window === 'undefined' ? global : window).__TMP_VAL__ = foo[0]) || true) && typeof (typeof window === 'undefined' ? global : window).__TMP_VAL__ === 'undefined' || (typeof window === 'undefined' ? global : window).__TMP_VAL__ === null;`
},

@@ -58,3 +53,3 @@ {

before: 'foo.bar["hoge"].isNil',
after: '"use strict";\n\nfoo.bar["hoge"] === null || foo.bar["hoge"] === void 0;'
after: `"use strict";\n\n(((typeof window === 'undefined' ? global : window).__TMP_VAL__ = foo.bar["hoge"]) || true) && typeof (typeof window === 'undefined' ? global : window).__TMP_VAL__ === 'undefined' || (typeof window === 'undefined' ? global : window).__TMP_VAL__ === null;`
},

@@ -64,3 +59,3 @@ {

before: 'bar[hoge].isNil',
after: '"use strict";\n\nbar[hoge] === null || bar[hoge] === void 0;'
after: `"use strict";\n\n(((typeof window === 'undefined' ? global : window).__TMP_VAL__ = bar[hoge]) || true) && typeof (typeof window === 'undefined' ? global : window).__TMP_VAL__ === 'undefined' || (typeof window === 'undefined' ? global : window).__TMP_VAL__ === null;`
}

@@ -67,0 +62,0 @@ ]

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