Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

36 wiersze
807 B

3 lat temu
  1. declare namespace stripJsonComments {
  2. interface Options {
  3. /**
  4. Replace comments with whitespace instead of stripping them entirely.
  5. @default true
  6. */
  7. readonly whitespace?: boolean;
  8. }
  9. }
  10. /**
  11. Strip comments from JSON. Lets you use comments in your JSON files!
  12. It will replace single-line comments `//` and multi-line comments `/**\/` with whitespace. This allows JSON error positions to remain as close as possible to the original source.
  13. @param jsonString - Accepts a string with JSON.
  14. @returns A JSON string without comments.
  15. @example
  16. ```
  17. const json = `{
  18. // Rainbows
  19. "unicorn": "cake"
  20. }`;
  21. JSON.parse(stripJsonComments(json));
  22. //=> {unicorn: 'cake'}
  23. ```
  24. */
  25. declare function stripJsonComments(
  26. jsonString: string,
  27. options?: stripJsonComments.Options
  28. ): string;
  29. export = stripJsonComments;