function replaceToSaveNonJSONValues(key, value) {

    // Remove `start` and `end` properties because of non-standard.
    if ((key === "start" || key === "end") && typeof value === "number") {
        return void 0;
    }

    // Save the values JSON cannot handle.
    // The `value` property of `Literal` node can have those values.
    switch (typeof value) {
        case "bigint":
            return `${Prefix.bigint}${value}n`;
        case "number":
            return Number.isFinite(value) ? value : `${Prefix.number}${value}`;
        case "object":
            return !(value instanceof RegExp) ? value : `${Prefix.RegExp}${value}`;
        case "undefined":
            throw new Error(`AST cannot have undefined as a property value.\nProperty name is '${key}'`);
        default:
            return value;
    }
}
Replace the values JSON cannot handle by strings.
The `replaceToRestoreNonJSONValues` function restores the replaced values.
@param {string} key The key to replace.
@param {any} value The value to replace.
@returns {any} If `value` parameter is a value JSON cannot handle, this
function returns a string value. If `key` parameter is `"start"` or `"end"`,
returns `undefined`. Otherwise, returns `value` parameter as is.
@throws {Error} If `value` is undefined
@private