index.d.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /**
  2. * @typedef Options
  3. * Configuration for `stringify`.
  4. * @property {boolean} [padLeft=true]
  5. * Whether to pad a space before a token.
  6. * @property {boolean} [padRight=false]
  7. * Whether to pad a space after a token.
  8. */
  9. /**
  10. * @typedef {Options} StringifyOptions
  11. * Please use `StringifyOptions` instead.
  12. */
  13. /**
  14. * Parse comma-separated tokens to an array.
  15. *
  16. * @param {string} value
  17. * Comma-separated tokens.
  18. * @returns {Array<string>}
  19. * List of tokens.
  20. */
  21. export function parse(value: string): Array<string>
  22. /**
  23. * Serialize an array of strings or numbers to comma-separated tokens.
  24. *
  25. * @param {Array<string|number>} values
  26. * List of tokens.
  27. * @param {Options} [options]
  28. * Configuration for `stringify` (optional).
  29. * @returns {string}
  30. * Comma-separated tokens.
  31. */
  32. export function stringify(
  33. values: Array<string | number>,
  34. options?: Options | undefined
  35. ): string
  36. /**
  37. * Configuration for `stringify`.
  38. */
  39. export type Options = {
  40. /**
  41. * Whether to pad a space before a token.
  42. */
  43. padLeft?: boolean | undefined
  44. /**
  45. * Whether to pad a space after a token.
  46. */
  47. padRight?: boolean | undefined
  48. }
  49. /**
  50. * Please use `StringifyOptions` instead.
  51. */
  52. export type StringifyOptions = Options