UNPKG

bbo

Version:

bbo is a utility library of zero dependencies for javascript.

26 lines (19 loc) 360 B
/** * Repeat item, times times */ function repeat(item, times) { var s = String(item); var target = ''; while (times > 0) { if (times % 2 === 1) { target += s; } if (times === 1) { break; } s += s; // eslint-disable-next-line no-param-reassign times = times >> 1; } return target; } export default repeat;