Skip to content
Myr

Fix Firefox compatibility for the `onDownloadProgress` option

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Fixes #455

authored by Sindre Sorhus · committed by Sindre Sorhus · parent da40323 · Browse files · 2 files+13 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+13 added−4 removed

  • other:+13 added−4 removed

2 files+13 added−4 removed

modified:source/core/constants.ts+2 added-1 removed
modified:source/core/Ky.ts+11 added-3 removed
5 unmodified lines
6import {deepMerge, mergeHeaders} from '../utils/merge.js';7import {normalizeRequestMethod, normalizeRetryOptions} from '../utils/normalize.js';8import {delay, timeout, TimeoutOptions} from '../utils/time.js';9import {ObjectEntries} from '../utils/types.js';10import {maxSafeTimeout, responseTypes, stop, supportsAbortController, supportsFormData, supportsStreams} from './constants.js';10import {11 maxSafeTimeout,12 responseTypes,13 stop,14 supportsAbortController,15 supportsFormData,16 supportsResponseStreams,17 supportsRequestStreams,18} from './constants.js';1920export class Ky {21 // eslint-disable-next-line @typescript-eslint/promise-function-async22 static create(input: Input, options: Options): ResponsePromise {
40 unmodified lines
63 if (typeof ky._options.onDownloadProgress !== 'function') {64 throw new TypeError('The `onDownloadProgress` option must be a function');65 }6659 if (!supportsStreams) {67 if (!supportsResponseStreams) {68 throw new Error('Streams are not supported in your environment. `ReadableStream` is missing.');69 }7071 return ky._stream(response.clone(), ky._options.onDownloadProgress);
90 unmodified lines
162 }163164 this.request = new globalThis.Request(this._input as RequestInfo, this._options as RequestInit);165158 if (supportsStreams) {166 if (supportsRequestStreams) {167 // @ts-expect-error - Types are outdated.168 this.request.duplex = 'half';169 }170
182 unmodified lines