Code coverage report for master/repeat.js

Statements: 100% (9 / 9)      Branches: 100% (2 / 2)      Functions: 100% (1 / 1)      Lines: 100% (8 / 8)      Ignored: none     

All files » master/ » repeat.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 161 1   1 9   9     9     2 2    
var makeString = require('./helper/makeString');
var strRepeat = require('./helper/strRepeat');
 
module.exports = function repeat(str, qty, separator) {
  str = makeString(str);
 
  qty = ~~qty;
 
  // using faster implementation if separator is not needed;
  if (separator == null) return strRepeat(str, qty);
 
  // this one is about 300x slower in Google Chrome
  for (var repeat = []; qty > 0; repeat[--qty] = str) {}
  return repeat.join(separator);
};