UNPKG

moltres-utils

Version:
40 lines (28 loc) 822 B
"use strict"; require("core-js/modules/es6.object.define-property"); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; require("core-js/modules/es6.number.constructor"); require("core-js/modules/es6.number.max-safe-integer"); var repeat = function repeat(string, n) { var result = ''; if (!string || n < 1 || n > Number.MAX_SAFE_INTEGER) { return result; } // Leverage the exponentiation by squaring algorithm for a faster repeat. // See https://en.wikipedia.org/wiki/Exponentiation_by_squaring for more details. do { if (n % 2) { result += string; } n = Math.floor(n / 2); if (n) { string += string; } } while (n); return result; }; var _default = repeat; exports.default = _default; //# sourceMappingURL=repeat.js.map