@woosh/meep-engine
Version:
Pure JavaScript game engine. Fully featured and production ready.
26 lines (21 loc) • 563 B
JavaScript
import { assert } from "../../assert.js";
/**
* Repeat a given piece of text a {@link count} times
* @example "ABC_" repeated 2 times results in "ABC_ABC_"
* @param {string} what
* @param {number} count
* @return {string}
*/
export function string_repeat(what, count) {
assert.isString(what, 'what');
assert.isNonNegativeInteger(count, 'count');
if (count <= 0) {
// special case
return "";
}
let out = what;
for (let i = 1; i < count; i++) {
out += what;
}
return out;
}