"use strict";
/**
 * Lightweight, dependency-free helpers for the WS subsystem.
 *
 * These exist as a separate module (rather than importing from
 * `src/classes/utils.ts`) so the WS subsystem doesn't pull in heavy
 * transitive deps (axios, decimal.js, token program) at module load.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.noop = void 0;
exports.toJson = toJson;
exports.toBuffer = toBuffer;
exports.blobEquals = blobEquals;
/** No-op callback — useful as a default for optional handlers. */
const noop = () => { };
exports.noop = noop;
/**
 * JSON.stringify with bigint support. Used to build stable, comparable
 * keys for filter sets that may contain bigint slot offsets etc.
 */
function toJson(object, inline = false) {
    const replacer = (_key, value) => (typeof value === 'bigint' ? value.toString() : value);
    return inline ? JSON.stringify(object, replacer) : JSON.stringify(object, replacer, 2);
}
/**
 * Convert a Uint8Array (possibly a subarray) to a Node Buffer for borsh
 * decode. Listeners call this on the small `data` blob returned by WS
 * notifications before handing it to `*.decode()`.
 */
function toBuffer(data) {
    return Buffer.isBuffer(data) ? data : Buffer.from(data);
}
/** Element-wise equality of two byte arrays (no allocation). */
function blobEquals(left, right) {
    if (left.length !== right.length) {
        return false;
    }
    for (let i = 0; i < left.length; ++i) {
        if (left[i] !== right[i]) {
            return false;
        }
    }
    return true;
}
//# sourceMappingURL=utils.js.map