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;
}