将ES6剩余参数转换为ES3:
var join = function (joinStr, ...items) {
return items.join(joinStr);
};
变成:
var join = function (joinStr) {
var items = [].slice.call(arguments, 1);
return items.join(joinStr);
};
用法:
var compile = require('es6-rest-params').compile;
var output = compile(mySource);
// 输出:{ code: '...' }
// 或者,如果需要源映射:
var output = compile(mySource, { sourceMap: true });
暂无评论