16e6b4cb8a3e0d1a0b1d1064022c86a73c9380e8d33a9bb1d066a59d1c041dfcaaa5cf913d97d9345e2bd537cc3d34cab934130f9d9fd14b2a50d3b585b904 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { F as FormatOptions } from './shared/confbox.9745c98f.js';
  2. /**
  3. *
  4. * Converts a [JSONC](https://github.com/microsoft/node-jsonc-parser) string into an object.
  5. *
  6. * @NOTE On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.
  7. *
  8. * @NOTE Comments and trailing commas are not preserved after parsing.
  9. *
  10. * @template T The type of the return value.
  11. * @param text The string to parse as JSONC.
  12. * @param options Parsing options.
  13. * @returns The JavaScript value converted from the JSONC string.
  14. */
  15. declare function parseJSONC<T = unknown>(text: string, options?: JSONCParseOptions): T;
  16. /**
  17. * Converts a JavaScript value to a [JSONC](https://github.com/microsoft/node-jsonc-parser) string.
  18. *
  19. * @NOTE Comments and trailing commas are not preserved in the output.
  20. *
  21. * @param value
  22. * @param options
  23. * @returns The JSON string converted from the JavaScript value.
  24. */
  25. declare function stringifyJSONC(value: any, options?: JSONCStringifyOptions): string;
  26. interface JSONCParseOptions extends FormatOptions {
  27. disallowComments?: boolean;
  28. allowTrailingComma?: boolean;
  29. allowEmptyContent?: boolean;
  30. errors?: JSONCParseError[];
  31. }
  32. interface JSONCStringifyOptions extends FormatOptions {
  33. }
  34. interface JSONCParseError {
  35. error: number;
  36. offset: number;
  37. length: number;
  38. }
  39. export { type JSONCParseError, type JSONCParseOptions, type JSONCStringifyOptions, parseJSONC, stringifyJSONC };