function constraint_to_multiple_of(val, multiple, minVal = 0, maxVal = null) {
    const a = val / multiple;
    let x = bankers_round(a) * multiple;

    if (maxVal !== null && x > maxVal) {
        x = Math.floor(a) * multiple;
    }

    if (x < minVal) {
        x = Math.ceil(a) * multiple;
    }

    return x;
}
Helper function to constrain a value to be a multiple of a number.
@param {number} val The value to constrain.
@param {number} multiple The number to constrain to.
@param {number} [minVal=0] The minimum value to constrain to.
@param {number} [maxVal=null] The maximum value to constrain to.
@returns {number} The constrained value.
@private