Sha256: 68a26faff715134d64a1d6f230da20f875271f3ed6a4195ab5902041b7708378
Contents?: true
Size: 519 Bytes
Versions: 69
Compression:
Stored size: 519 Bytes
Contents
var toString = require('../lang/toString'); var toInt = require('../number/toInt'); /** * Repeat string n times */ function repeat(str, n){ var result = ''; str = toString(str); n = toInt(n); if (n < 1) { return ''; } while (n > 0) { if (n % 2) { result += str; } n = Math.floor(n / 2); str += str; } return result; } module.exports = repeat;
Version data entries
69 entries across 69 versions & 2 rubygems