{"version":3,"file":"index-node18.mjs","sources":["../src/stringify.ts","../src/parse.ts"],"sourcesContent":["import type { ExtendedJsonValue } from './ExtendedJsonValue';\n\ntype JsonReplacer = (\n  key: string,\n  value: any,\n) => Record<string, any> | boolean | number | string | undefined;\n\n// const internalReplacer = (key, value) => {\n//   return value;\n// };\n\n/**\n * @param {*} value The value to convert to a JSON string\n * @param {function} [replacer] A function that alters the behavior of the stringification process, or an array of String and Number objects that serve as a whitelist for selecting the properties of the value object to be included in the JSON string. If this value is null or not provided, all properties of the object are included in the resulting JSON string.\n * @param {string|number} [space]\n * @return {string}\n */\nexport default function stringify(\n  value: ExtendedJsonValue,\n  replacer?: JsonReplacer,\n  space?: number | string,\n): string {\n  return JSON.stringify(\n    value,\n    // replacer == null ? internalReplacer : (key, value) => replacer(key, internalReplacer(value)),\n    replacer,\n    space,\n  );\n}\n","import type { ExtendedJsonValue } from './ExtendedJsonValue';\n\nconst regexpStringDate =\n  /^(\\d{4})-(\\d{2})-(\\d{2})T(\\d{2}):(\\d{2}):(\\d{2}(?:\\.\\d*)?)Z$/;\n\ntype JsonReviver = <T extends ExtendedJsonValue>(\n  key: string,\n  value: T,\n) => ExtendedJsonValue;\n\nconst internalReviver: JsonReviver = function <T extends ExtendedJsonValue>(\n  key: string,\n  value: T,\n): Date | T {\n  if (typeof value === 'string') {\n    const matchDate = regexpStringDate.exec(value);\n    if (matchDate) {\n      return new Date(\n        Date.UTC(\n          +matchDate[1],\n          +matchDate[2] - 1,\n          +matchDate[3],\n          +matchDate[4],\n          +matchDate[5],\n          +matchDate[6],\n        ),\n      );\n    }\n  }\n\n  return value;\n};\n\n/**\n * @param  {string}   text      The string to parse as JSON\n * @param  {function} [reviver] If a function, prescribes how the value originally produced by parsing is transformed, before being returned\n * @return {*}\n */\nexport default function parse<Value = ExtendedJsonValue>(\n  text: string,\n  reviver?: JsonReviver,\n): Value {\n  return JSON.parse(\n    text,\n    reviver == null\n      ? internalReviver\n      : (key, value) => reviver(key, internalReviver(key, value)),\n  ) as Value;\n}\n"],"names":["stringify","value","replacer","space","JSON","regexpStringDate","internalReviver","key","matchDate","exec","Date","UTC","parse","text","reviver"],"mappings":"AAOA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,SAASA,CAC/BC,KAAwB,EACxBC,QAAuB,EACvBC,KAAuB,EACf;AACR,EAAA,OAAOC,IAAI,CAACJ,SAAS,CACnBC,KAAK;AACL;EACAC,QAAQ,EACRC,KACF,CAAC,CAAA;AACH;;AC1BA,MAAME,gBAAgB,GACpB,8DAA8D,CAAA;AAOhE,MAAMC,eAA4B,GAAG,UACnCC,GAAW,EACXN,KAAQ,EACE;AACV,EAAA,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;AAC7B,IAAA,MAAMO,SAAS,GAAGH,gBAAgB,CAACI,IAAI,CAACR,KAAK,CAAC,CAAA;AAC9C,IAAA,IAAIO,SAAS,EAAE;MACb,OAAO,IAAIE,IAAI,CACbA,IAAI,CAACC,GAAG,CACN,CAACH,SAAS,CAAC,CAAC,CAAC,EACb,CAACA,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,EACjB,CAACA,SAAS,CAAC,CAAC,CAAC,EACb,CAACA,SAAS,CAAC,CAAC,CAAC,EACb,CAACA,SAAS,CAAC,CAAC,CAAC,EACb,CAACA,SAAS,CAAC,CAAC,CACd,CACF,CAAC,CAAA;AACH,KAAA;AACF,GAAA;AAEA,EAAA,OAAOP,KAAK,CAAA;AACd,CAAC,CAAA;;AAED;AACA;AACA;AACA;AACA;AACe,SAASW,KAAKA,CAC3BC,IAAY,EACZC,OAAqB,EACd;AACP,EAAA,OAAOV,IAAI,CAACQ,KAAK,CACfC,IAAI,EACJC,OAAO,IAAI,IAAI,GACXR,eAAe,GACf,CAACC,GAAG,EAAEN,KAAK,KAAKa,OAAO,CAACP,GAAG,EAAED,eAAe,CAACC,GAAG,EAAEN,KAAK,CAAC,CAC9D,CAAC,CAAA;AACH;;;;"}