es6Repeat.js 216 B

1234567891011121314
  1. 'use strict';
  2. module.exports = function (str, len, ch) {
  3. str = str + '';
  4. len = len - str.length;
  5. if (len <= 0) return str;
  6. if (!ch && ch !== 0) ch = ' ';
  7. ch = ch + '';
  8. return ch.repeat(len) + str;
  9. };