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 1.0.0 to 1.0.1

12

CHANGELOG.md

@@ -0,1 +1,11 @@

v1.0.1
---
Install dependencies.
v1.0.0
---
This greatly simplifies the logic of the plugin + adds eval tests to make sure the code actually runs!
Special Thanks @shnhrrsn
v0.0.7

@@ -18,3 +28,3 @@ ---

```
**after**

@@ -21,0 +31,0 @@

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

@@ -33,3 +33,7 @@ "main": "src",

"xo": "^0.18.2"
},
"dependencies": {
"babel-template": "^6.26.0",
"babel-types": "^6.26.0"
}
}

31

src/index.js

@@ -6,3 +6,5 @@ 'use strict'

const isNilWrapper = template('(function (val) { return val === null || typeof val === \'undefined\' })')
const isNilWrapper = template(
'(function (val) { return val === null || typeof val === \'undefined\' })'
)

@@ -13,3 +15,3 @@ function addIsNilHelper() {

let declar = this.declarations[name]
const declar = this.declarations[name]
if (declar) {

@@ -24,7 +26,7 @@ return declar

let generator = this.get('helperGenerator')
let runtime = this.get('helpersNamespace')
const generator = this.get('helperGenerator')
const runtime = this.get('helpersNamespace')
if (generator) {
let res = generator(name)
const res = generator(name)

@@ -38,4 +40,7 @@ if (res) {

let ref = isNilWrapper().expression
let uid = this.declarations[name] = this.scope.generateUidIdentifier(name)
const ref = isNilWrapper().expression
/* eslint no-multi-assign: [0] */
const uid = (this.declarations[name] = this.scope.generateUidIdentifier(
name
))

@@ -59,3 +64,6 @@ ref._compact = true

if (property.name !== 'isNil' || path.container.type === 'CallExpression') {
if (
property.name !== 'isNil' ||
path.container.type === 'CallExpression'
) {
return

@@ -65,6 +73,5 @@ }

const isNilWrapper = addIsNilHelper.call(state.file).name
path.replaceWith(t.callExpression(
t.identifier(isNilWrapper),
[node.object]
))
path.replaceWith(
t.callExpression(t.identifier(isNilWrapper), [node.object])
)
}

@@ -71,0 +78,0 @@ }

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