babel/packages/babel-plugin-transform-es2015-arrow-functions
Justin Ridgewell c2ed9de7fb Flip default parameter template (#4515)
* Flip default parameter template

YMMV, I saved ~10b on a 2kb library. Not noticeable at the small scale, by why not do it anyway?

I've (unscientifically) found that flipping the default parameter conditional yields better gzip results. I think this is due to the slightly longer string it can now repeatedly match:

```js
// old
var param = arguments.length <= 0 || void 0 === arguments[0] ? null : arguments[0]
--------------------------------------------------------------^

// new
var param = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : null
------------------------------------------------------------------------^
```

Though it's entirely likely gzip will also choose up to the index of the arguments if you many default parameters at different indexes.

* Update tests
2016-09-25 14:05:53 -07:00
..
2015-10-29 17:51:24 +00:00
2016-05-02 19:43:49 -04:00

babel-plugin-transform-es2015-arrow-functions

Compile ES2015 arrow functions to ES5

Installation

$ npm install babel-plugin-transform-es2015-arrow-functions

Usage

.babelrc

// without options
{
  "plugins": ["transform-es2015-arrow-functions"]
}

// with options
{
  "plugins": [
    ["transform-es2015-arrow-functions", { "spec": true }]
  ]
}

Via CLI

$ babel --plugins transform-es2015-arrow-functions script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["transform-es2015-arrow-functions"]
});