deno.land / x / esm@v135_2 / server / embed / polyfills / node_fetch.js

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
export 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);};
esm

Version Info

Tagged at
a year ago