import { isUint8Array } from "node:util/types";
export function stringifyReplacer(key, value) {
    // Ensure that Uint8Arrays are serialized as if they were Buffers
    // to keep the API backwards compatible
    if (isUint8Array(value)) {
        return Buffer.from(value).toJSON();
    }
    // Convert Map to object for JSON serialization
    if (value instanceof Map) {
        return Object.fromEntries(value);
    }
    return value;
}
