Version 1
[yaffs-website] / node_modules / underscore.string / repeat.js
diff --git a/node_modules/underscore.string/repeat.js b/node_modules/underscore.string/repeat.js
new file mode 100644 (file)
index 0000000..71228ed
--- /dev/null
@@ -0,0 +1,16 @@
+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
+  /*eslint no-empty: 0*/
+  for (var repeat = []; qty > 0; repeat[--qty] = str) {}
+  return repeat.join(separator);
+};