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

replace the comparing of null or undefined with isNil

  • 0.0.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
22
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

babel-plugin-transform-isNil

About

I like Existential Operator in CoffeeScript. CoffeeScript can be written as follows:

hoge?

Become to JavaScript

hoge == null

Same meaning

hoge === null || hoge === undefined

I want to do the same thing in JavaScript.

Installation

$ npm install --save babel-plugin-transform-isnil

Example

In

if (foo.isNil) {
  console.log('foo is null or undefined');
}

Out

if (foo === null || foo === undefined) {
  console.log('foo is null or undefined');
}

In

if (hoge.poge.isNil && foo.bar.isNil) {
  console.log('hoge.poge and foo.bar is null or undefined');
}

Out

if ((hoge.poge === null || hoge.poge === undefined) && (foo.bar === null || foo.bar === undefined)) {
  console.log('hoge.poge and foo.bar is null or undefined');
}

In

if (hoge.poge().isNil) {
  console.log('returned value of hoge.poge() function is null or undefined');
}

Out

if (hoge.poge() === null || hoge.poge() === undefined) {
  console.log('returned value of hoge.poge() function is null or undefined');
}

In

if (hoge.poge(hoge).isNil) {
  console.log('returned value of hoge.poge() function is null or undefined');
}

Out

if (hoge.poge(hoge) === null || hoge.poge(hoge) === undefined) {
  console.log('returned value of hoge.poge() function is null or undefined');
}

TODO

I can't think of implementation method. :cry:

May possibly to stop the support of the fuunction. :persevere:

In

if (hoge().poge(hoge).isNil) {
  console.log('hoge.poge and foo.bar is null or undefined');
}

Out

if (hoge().poge(hoge) === null || hoge().poge(hoge) === undefined) {
  console.log('hoge.poge and foo.bar is null or undefined');
}

Usage

Via .babelrc

{
  "plugins": ["babel-plugin-transform-isnil"]
}

Development

Requirement global

  • Node v6.2.0
  • npm v3.7.2
$ git clone https://github.com/MaxMEllon/babel-plugin-transform-isNil
$ cd babel-plugin-transform-isNil
$ npm install

$ npm test

LICENSE

MIT

Keywords

FAQs

Package last updated on 21 Oct 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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