ini.d.mts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /**
  2. * Converts an [INI](https://www.ini.org/ini-en.html) string into an object.
  3. *
  4. * **Note:** Style and indentation are not preserved currently.
  5. */
  6. declare function parseINI<T = unknown>(text: string, options?: INIParseOptions): T;
  7. /**
  8. * Converts a JavaScript value to an [INI](https://www.ini.org/ini-en.html) string.
  9. *
  10. * **Note:** Style and indentation are not preserved currently.
  11. */
  12. declare function stringifyINI(value: any, options?: INIStringifyOptions): string;
  13. interface INIParseOptions {
  14. /**
  15. * Whether to append `[]` to array keys.
  16. *
  17. * Some parsers treat duplicate names by themselves as arrays.
  18. */
  19. bracketedArray?: boolean;
  20. }
  21. interface INIStringifyOptions {
  22. /**
  23. * Whether to insert spaces before & after `=` character.
  24. * Enabled by default.
  25. */
  26. whitespace?: boolean;
  27. /**
  28. * Whether to align the `=` character for each section.
  29. */
  30. align?: boolean;
  31. /**
  32. * Identifier to use for global items
  33. * and to prepend to all other sections.
  34. */
  35. section?: string;
  36. /**
  37. * Whether to sort all sections & their keys alphabetically.
  38. */
  39. sort?: boolean;
  40. /**
  41. * Whether to insert a newline after each section header.
  42. */
  43. newline?: boolean;
  44. /**
  45. * Which platforms line-endings should be used.
  46. *
  47. * win32 -> CR+LF
  48. * other -> LF
  49. *
  50. * Default is the current platform
  51. */
  52. platform?: string;
  53. /**
  54. * Whether to append `[]` to array keys.
  55. *
  56. * Some parsers treat duplicate names by themselves as arrays
  57. */
  58. bracketedArray?: boolean;
  59. }
  60. export { parseINI, stringifyINI };
  61. export type { INIParseOptions, INIStringifyOptions };