es6-rest-params

0.3.1 • Public • Published

Convert ES6 rest params to ES3:

var join = function(joinStr, ...items) {
  return items.join(joinStr);
};

becomes:

var join = function(joinStr) {
  var items = [].slice.call(arguments, 1);
  return items.join(joinStr);
};

Usage

var compile = require('es6-rest-params').compile;
 
var output = compile(mySource);  // outputs { code: "..." }
 
// or, for source maps:
var output = compile(mySource, {
  sourceFileName: 'foo.js',
  sourceMapName: 'foo.js.map'
});  // outputs { code: "...", map: {...} }

Resources

Source map example

Thanks to Facebook's jstransform for the implementation strategy :)

Readme

Keywords

none

Package Sidebar

Install

npm i es6-rest-params

Weekly Downloads

192

Version

0.3.1

License

MIT

Last publish

Collaborators

  • tboyt
  • eventualbuddha