@junobuild/analytics
Version:
Tracker for Juno analytics
26 lines (25 loc) • 1.15 kB
TypeScript
/**
* A custom replacer for `JSON.stringify` that converts specific types not natively supported
* by the API into JSON-compatible formats.
*
* Supported conversions:
* - `BigInt` → `{ "__bigint__": string }`
*
* @param {string} _key - Ignored. Only provided for API compatibility.
* @param {unknown} value - The value to transform before stringification.
* @returns {unknown} The transformed value if it matches a known type, otherwise the original value.
*/
export declare const jsonReplacer: (_key: string, value: unknown) => unknown;
/**
* A custom reviver for `JSON.parse` that reconstructs specific types from their JSON-encoded representations.
*
* This reverses the transformations applied by `jsonReplacer`, restoring the original types.
*
* Supported conversions:
* - `{ "__bigint__": string }` → `BigInt`
*
* @param {string} _key - Ignored but provided for API compatibility.
* @param {unknown} value - The parsed value to transform.
* @returns {unknown} The reconstructed value if it matches a known type, otherwise the original value.
*/
export declare const jsonReviver: (_key: string, value: unknown) => unknown;