deno.land / x / esm@v135_2 / server / embed / polyfills / node_fetch.js
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859export const Blob = globalThis.Blobexport const File = globalThis.Fileexport const FormData = globalThis.FormDataexport const Headers = globalThis.Headersexport const Request = globalThis.Requestexport const Response = globalThis.Responseexport const AbortController = globalThis.AbortController
export const fetch = globalThis.fetch || (() => { throw new Error('global fetch is not available!') })export default fetch
export class AbortError extends Error { }export class FetchError extends Error { }
export async function blobFrom(path, type) { if (typeof Deno !== "undefined") { const file = await Deno.open(path); const res = new Response(file.readable); return new Blob([await res.blob()], { type }); } throw new Error("blobFrom is not supported in browser");}
export function blobFromSync(path, type) { if (typeof Deno !== "undefined") { const data = Deno.readFileSync(path); return new Blob([data], { type }); } throw new Error("blobFromSync is not supported in browser");}
export async function fileFrom(path, type) { if (typeof Deno !== "undefined") { const file = await Deno.open(path); const res = new Response(file.readable); return new File([await res.blob()], path.split(/[\/\\]/).pop(), { type }); } throw new Error("blobFrom is not supported in browser");}
export function fileFromSync(path, type) { if (typeof Deno !== "undefined") { const data = Deno.readFileSync(path); return new File([data], path.split(/[\/\\]/).pop(), { type }); } throw new Error("blobFromSync is not supported in browser");}
const redirectStatus = new Set([301, 302, 303, 307, 308]);
/** * Redirect code matching * * @param {number} code - Status code * @return {boolean} */export const isRedirect = code => { return redirectStatus.has(code);};
Version Info