UNPKG

bbo

Version:

bbo is a utility library of zero dependencies for javascript.

28 lines (20 loc) 377 B
'use strict'; /** * 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; } module.exports = repeat;