{
  "version": 3,
  "sources": ["../../src/codec-json/index.ts"],
  "sourcesContent": ["import { OpaqueType } from \"../opaque-type/index.js\";\n\ntype JsonSerializablePrimitive = string | number | boolean;\n\n/**\n * Represents a record ({ [key: string]: object}) that can be serialized to\n * JSON.\n */\nexport interface JsonSerializableRecord {\n  [key: string]:\n    | JsonSerializablePrimitive\n    | JsonSerializablePrimitive[]\n    | JsonSerializableRecord\n    | JsonSerializableRecord[]\n    | null\n    | null[]\n    | undefined\n    | undefined[];\n}\n\n/**\n * Represents an object that can be serialized to JSON.\n */\nexport type JsonSerializable =\n  | JsonSerializablePrimitive\n  | JsonSerializablePrimitive[]\n  | JsonSerializableRecord\n  | JsonSerializableRecord[];\n\n/**\n * Represents an object that has been converted to a JSON string.\n */\nexport type JsonEncoded<T extends JsonSerializable = JsonSerializable> =\n  OpaqueType<string, T>;\n\n/**\n * Converts a JavaScript value to a typed JavaScript Object Notation (JSON) string.\n * @param value A JavaScript value, usually an object or array, to be converted.\n * @param replacer A function that transforms the results.\n * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.\n * @example\n * ```ts\n * const userJson = jsonEncode({ id: 1, name: \"Jane Doe\" });\n * console.log(userJson); // '{\"id\":1,\"name\":\"Jane Doe\"}'\n *\n * const user = jsonDecode(userJson);\n * type UserType = typeof user; // { id: number; name: string }\n * ```\n */\nexport function jsonEncode<T extends JsonSerializable>(\n  value: T,\n  replacer?: ((key: string, value: any) => any) | undefined,\n  space?: string | number,\n): JsonEncoded<T>;\n\n/**\n * Converts a JavaScript value to a typed JavaScript Object Notation (JSON) string.\n * @param value A JavaScript value, usually an object or array, to be converted.\n * @param replacer An array of strings and numbers that acts as an approved list for selecting the object properties that will be stringified.\n * @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.\n */\nexport function jsonEncode<T extends JsonSerializable>(\n  value: T,\n  replacer?: (number | string)[] | undefined,\n  space?: string | number,\n): JsonEncoded<T>;\n\nexport function jsonEncode<T extends JsonSerializable>(\n  value: T,\n  replacer?: any,\n  space?: string | number | undefined,\n): JsonEncoded<T> {\n  return JSON.stringify(value, replacer, space) as JsonEncoded<T>;\n}\n\n/**\n * Converts a JavaScript Object Notation (JSON) string into an object.\n *\n * @param json A valid JSON string.\n * @param reviver A function that transforms the results. This function is called for each member of the object.\n * If a member contains nested objects, the nested objects are transformed before the parent object is.\n * @example\n * ```ts\n * const userJson = jsonEncode({ id: 1, name: \"Jane Doe\" });\n * const user = jsonDecode(userJson);\n * type UserType = typeof user; // { id: number; name: string }\n * ```\n */\nexport function jsonDecode<T extends JsonSerializable>(\n  json: JsonEncoded<T>,\n  reviver?: ((this: any, key: string, value: any) => any) | undefined,\n) {\n  return JSON.parse(json, reviver) as T;\n}\n"],
  "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gBAAAE,EAAA,eAAAC,IAAA,eAAAC,EAAAJ,GAmEO,SAASG,EACdE,EACAC,EACAC,EACgB,CAChB,OAAO,KAAK,UAAUF,EAAOC,EAAUC,CAAK,CAC9C,CAeO,SAASL,EACdM,EACAC,EACA,CACA,OAAO,KAAK,MAAMD,EAAMC,CAAO,CACjC",
  "names": ["codec_json_exports", "__export", "jsonDecode", "jsonEncode", "__toCommonJS", "value", "replacer", "space", "json", "reviver"]
}
