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 fooisNil console;
Out
if foo === null || foo === undefined console;
In
if hogepogeisNil && foobarisNil console;
Out
if hogepoge === null || hogepoge === undefined && foobar === null || foobar === undefined console;
In
if hogeisNil console;
Out
if hoge === null || hoge === undefined console;
In
if hogeisNil console;
Out
if hoge === null || hoge === undefined console;
Usage
.babelrc
Via
Development
Requirement global
- Node v4 or above
$ git clone https://github.com/MaxMEllon/babel-plugin-transform-isNil$ cd babel-plugin-transform-isNil$ npm install $ npm test