Code coverage report for 6to5/transformation/transformers/rest-parameters.js

Statements: 100% (14 / 14)      Branches: 100% (4 / 4)      Functions: 100% (1 / 1)      Lines: 100% (12 / 12)      Ignored: none     

All files » 6to5/transformation/transformers/ » rest-parameters.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 251 1   1 209   7 7   7 7   7   7           7   7    
var util = require("../../util");
var t    = require("../../types");
 
exports.Function = function (node, parent, file) {
  if (!node.rest) return;
 
  var rest = node.rest;
  delete node.rest;
 
  var templateName = "arguments-slice-assign";
  if (node.params.length) templateName += "-arg";
 
  t.ensureBlock(node);
 
  var template = util.template(templateName, {
    SLICE_KEY: file.addDeclaration("slice"),
    VARIABLE_NAME: rest,
    SLICE_ARG: t.literal(node.params.length)
  });
 
  template.declarations[0].init.arguments[0]._ignoreAliasFunctions = true;
 
  node.body.body.unshift(template);
};