5dec8bfccd0d256b6d8041ed2dd1c1bb5816f6bb29a7b394dce3c1c46ccb73298a0f8f96472cde027203b85a449f605d6cfb0e7329536321c9d3556e36c6d3 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { F as FormatOptions } from './shared/confbox.9745c98f.cjs';
  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 };