function incrementSemVer(value, target = 'patch', increment = 1) {
    const found = value.match(REGEXP_SEMVER);
    if (!found) {
        throw new TypeError(
            `Expected a SemVer version number, received [${value}]`
        );
    }

    if (Array.isArray(target)) {
        for (const group of target) {
            if (found.groups[group] != null) {
                target = group;
                break;
            }
        }
    }

    if (!target || !found.groups[target]) {
        throw new TypeError(
            `Expected a supported SemVer segment, received [${target}]`
        );
    }

    const segments = {
        'major':         '',
        'minor':         '.',
        'patch':         '.',
        'prerelease':    '-',
        'buildmetadata': '+',
    };

    let replacement = '';

    for (const [ segment, delimiter ] of Object.entries(segments)) {
        if (found.groups?.[segment] != null) {
            const newVersion = (segment === target)
                ? incrementNumber(found.groups[segment], increment)
                : found.groups[segment];

            replacement += `${delimiter}${newVersion}`;
        }
    }

    return value.replace(found[0], replacement);
}
Increments the given SemVer version number.

@param  {string}          value     - The version to mutate.
@param  {string|string[]} [target]  - The segment to increment, one of:
    'major', 'minor', 'patch', ~~'prerelease'~~, 'buildmetadata'.
@param  {string|int}      [increment=1] - The amount to increment by.
@return {string}
@throws TypeError If the version or target are invalid.