Code coverage report for harmonizer/util/spread.js

Statements: 100% (16 / 16)      Branches: 75% (3 / 4)      Functions: 100% (1 / 1)      Lines: 100% (16 / 16)      Ignored: none     

All files » harmonizer/util/ » spread.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19  1 1 1 1 1 1 1 1 7 2 2 2 2 2 2   7  
'use strict';
var objectPatternB = require('nodes');
var nodes = objectPatternB.nodes;
var objectPatternA = require('./id');
var getUniqueName = objectPatternA.getUniqueName;
var objectPattern = require('./string');
var express = objectPattern.express;
var spread = 'function() {\n  var array = [], last = arguments.length - 1;\n  for (var i = 0; i < last; i++) array.push(arguments[i]);\n  var iterator = arguments[last][\'@@iterator\'](), step;\n  while (!(step = iterator.next()).done) array.push(step.value);\n  return array;\n}';
exports.getSpreadId = function (node) {
  if (!node.spreadId) {
    var spreadName = getUniqueName(node, 'spread');
    var declaration = express('var ' + spreadName + ' = ' + spread);
    var id = declaration.declarations[0].id;
    var body = nodes.Function.test(node) ? node.body.body : node.body;
    body.unshift(declaration);
    node.spreadId = id;
  }
  return node.spreadId;
};