php.js
Version:
Use phpjs functions as required.
24 lines (22 loc) • 640 B
JavaScript
module.exports=function(){ return str_repeat.apply(exports,arguments) };
function str_repeat(input, multiplier) {
// discuss at: http://phpjs.org/functions/str_repeat/
// original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// improved by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
// improved by: Ian Carter (http://euona.com/)
// example 1: str_repeat('-=', 10);
// returns 1: '-=-=-=-=-=-=-=-=-=-='
var y = '';
while (true) {
if (multiplier & 1) {
y += input;
}
multiplier >>= 1;
if (multiplier) {
input += input;
} else {
break;
}
}
return y;
}