Sin descripción
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. export = fetch;
  2. /**
  3. * Node-style callback as used by {@link util.fetch}.
  4. * @typedef FetchCallback
  5. * @type {function}
  6. * @param {?Error} error Error, if any, otherwise `null`
  7. * @param {string} [contents] File contents, if there hasn't been an error
  8. * @returns {undefined}
  9. */
  10. type FetchCallback = (error: Error, contents?: string) => void;
  11. /**
  12. * Options as used by {@link util.fetch}.
  13. * @typedef FetchOptions
  14. * @type {Object}
  15. * @property {boolean} [binary=false] Whether expecting a binary response
  16. * @property {boolean} [xhr=false] If `true`, forces the use of XMLHttpRequest
  17. */
  18. interface FetchOptions {
  19. binary?: boolean;
  20. xhr?: boolean
  21. }
  22. /**
  23. * Fetches the contents of a file.
  24. * @memberof util
  25. * @param {string} filename File path or url
  26. * @param {FetchOptions} options Fetch options
  27. * @param {FetchCallback} callback Callback function
  28. * @returns {undefined}
  29. */
  30. declare function fetch(filename: string, options: FetchOptions, callback: FetchCallback): void;
  31. /**
  32. * Fetches the contents of a file.
  33. * @name util.fetch
  34. * @function
  35. * @param {string} path File path or url
  36. * @param {FetchCallback} callback Callback function
  37. * @returns {undefined}
  38. * @variation 2
  39. */
  40. declare function fetch(path: string, callback: FetchCallback): void;
  41. /**
  42. * Fetches the contents of a file.
  43. * @name util.fetch
  44. * @function
  45. * @param {string} path File path or url
  46. * @param {FetchOptions} [options] Fetch options
  47. * @returns {Promise<string|Uint8Array>} Promise
  48. * @variation 3
  49. */
  50. declare function fetch(path: string, options?: FetchOptions): Promise<(string|Uint8Array)>;