Skip to content

Commit

Permalink
fix(fetch): enhance fetch API detection; (#6413)
Browse files Browse the repository at this point in the history
  • Loading branch information
DigitalBrainJS committed May 21, 2024
1 parent 67d1373 commit 4f79aef
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/adapters/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ const fetchProgressDecorator = (total, fn) => {
}));
}

const isFetchSupported = typeof fetch !== 'undefined';
const isReadableStreamSupported = isFetchSupported && typeof ReadableStream !== 'undefined';
const isFetchSupported = typeof fetch === 'function' && typeof Request === 'function' && typeof Response === 'function';
const isReadableStreamSupported = isFetchSupported && typeof ReadableStream === 'function';

// used only inside the fetch adapter
const encodeText = isFetchSupported && (typeof TextEncoder !== 'undefined' ?
const encodeText = isFetchSupported && (typeof TextEncoder === 'function' ?
((encoder) => (str) => encoder.encode(str))(new TextEncoder()) :
async (str) => new Uint8Array(await new Response(str).arrayBuffer())
);
Expand Down

0 comments on commit 4f79aef

Please sign in to comment.