index.d.mts 1.6 KB

12345678910111213141516171819202122232425262728293031323334
  1. export { JSON5ParseOptions, JSON5StringifyOptions, parseJSON5, stringifyJSON5 } from './json5.mjs';
  2. export { JSONCParseError, JSONCParseOptions, parseJSONC, stringifyJSONC } from './jsonc.mjs';
  3. export { YAMLParseOptions, YAMLStringifyOptions, parseYAML, stringifyYAML } from './yaml.mjs';
  4. import { F as FormatOptions } from './shared/confbox.B202Uz6F.mjs';
  5. export { parseTOML, stringifyTOML } from './toml.mjs';
  6. export { INIParseOptions, INIStringifyOptions, parseINI, stringifyINI } from './ini.mjs';
  7. /**
  8. * Converts a [JSON](https://www.json.org/json-en.html) string into an object.
  9. *
  10. * Indentation status is auto-detected and preserved when stringifying back using `stringifyJSON`
  11. */
  12. declare function parseJSON<T = unknown>(text: string, options?: JSONParseOptions): T;
  13. /**
  14. * Converts a JavaScript value to a [JSON](https://www.json.org/json-en.html) string.
  15. *
  16. * Indentation status is auto detected and preserved when using value from parseJSON.
  17. */
  18. declare function stringifyJSON(value: any, options?: JSONStringifyOptions): string;
  19. interface JSONParseOptions extends FormatOptions {
  20. /**
  21. * A function that transforms the results. This function is called for each member of the object.
  22. */
  23. reviver?: (this: any, key: string, value: any) => any;
  24. }
  25. interface JSONStringifyOptions extends FormatOptions {
  26. /**
  27. * A function that transforms the results. This function is called for each member of the object.
  28. */
  29. replacer?: (this: any, key: string, value: any) => any;
  30. }
  31. export { parseJSON, stringifyJSON };
  32. export type { JSONParseOptions, JSONStringifyOptions };