/**
 * Returns the sum of the number of matches of the patterns in the string.
 * @param patterns Patterns to match in the string.
 */
export function count(str, ...patterns) {
    let n = 0;
    for (const p of patterns) {
        if (!p.global) {
            throw new Error('expected RegExp to be global (or else count is inaccurate)');
        }
        const m = str.match(p);
        if (m) {
            n += m.length;
        }
    }
    return n;
}
export function numberWithCommas(x) {
    return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
}
export function pluralize(str, n, plural = str + 's') {
    return n === 1 ? str : plural;
}
//# sourceMappingURL=strings.js.map