@cloudpss/fetch 0.4.12 → 0.4.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,17 +1,17 @@
1
- export declare const fetch: typeof globalThis.fetch;
2
- export declare const Headers: {
3
- new (init?: HeadersInit | undefined): Headers;
4
- prototype: Headers;
5
- };
6
- export declare const Response: {
7
- new (body?: BodyInit | null | undefined, init?: ResponseInit | undefined): Response;
8
- prototype: Response;
9
- error(): Response;
10
- redirect(url: string | URL, status?: number | undefined): Response;
11
- };
12
- export declare const Request: {
13
- new (input: RequestInfo | URL, init?: RequestInit | undefined): Request;
14
- prototype: Request;
15
- };
16
- export declare const agent: unknown;
17
- export default fetch;
1
+ export declare const fetch: typeof globalThis.fetch;
2
+ export declare const Headers: {
3
+ new (init?: HeadersInit | undefined): Headers;
4
+ prototype: Headers;
5
+ };
6
+ export declare const Response: {
7
+ new (body?: BodyInit | null | undefined, init?: ResponseInit | undefined): Response;
8
+ prototype: Response;
9
+ error(): Response;
10
+ redirect(url: string | URL, status?: number | undefined): Response;
11
+ };
12
+ export declare const Request: {
13
+ new (input: RequestInfo | URL, init?: RequestInit | undefined): Request;
14
+ prototype: Request;
15
+ };
16
+ export declare const agent: unknown;
17
+ export default fetch;
@@ -1,10 +1,10 @@
1
- if (typeof globalThis == 'undefined' || typeof globalThis.fetch != 'function') {
2
- throw new Error(`fetch is not defined on the global object, you should load polyfill of globalThis and fetch.`);
3
- }
4
- export const fetch = globalThis.fetch;
5
- export const Headers = globalThis.Headers;
6
- export const Response = globalThis.Response;
7
- export const Request = globalThis.Request;
8
- export const agent = undefined;
9
- export default fetch;
1
+ if (typeof globalThis == 'undefined' || typeof globalThis.fetch != 'function') {
2
+ throw new Error(`fetch is not defined on the global object, you should load polyfill of globalThis and fetch.`);
3
+ }
4
+ export const fetch = globalThis.fetch;
5
+ export const Headers = globalThis.Headers;
6
+ export const Response = globalThis.Response;
7
+ export const Request = globalThis.Request;
8
+ export const agent = undefined;
9
+ export default fetch;
10
10
  //# sourceMappingURL=index-browser.js.map
package/dist/index.d.ts CHANGED
@@ -1,16 +1,16 @@
1
- export declare const fetch: typeof globalThis.fetch, agent: unknown;
2
- export declare const Headers: {
3
- new (init?: HeadersInit | undefined): Headers;
4
- prototype: Headers;
5
- };
6
- export declare const Response: {
7
- new (body?: BodyInit | null | undefined, init?: ResponseInit | undefined): Response;
8
- prototype: Response;
9
- error(): Response;
10
- redirect(url: string | URL, status?: number | undefined): Response;
11
- };
12
- export declare const Request: {
13
- new (input: RequestInfo | URL, init?: RequestInit | undefined): Request;
14
- prototype: Request;
15
- };
16
- export default fetch;
1
+ export declare const fetch: typeof globalThis.fetch, agent: unknown;
2
+ export declare const Headers: {
3
+ new (init?: HeadersInit | undefined): Headers;
4
+ prototype: Headers;
5
+ };
6
+ export declare const Response: {
7
+ new (body?: BodyInit | null | undefined, init?: ResponseInit | undefined): Response;
8
+ prototype: Response;
9
+ error(): Response;
10
+ redirect(url: string | URL, status?: number | undefined): Response;
11
+ };
12
+ export declare const Request: {
13
+ new (input: RequestInfo | URL, init?: RequestInit | undefined): Request;
14
+ prototype: Request;
15
+ };
16
+ export default fetch;
package/dist/index.js CHANGED
@@ -1,29 +1,29 @@
1
- import ProxyAgent from 'proxy-agent';
2
- import nodeFetch, { Headers as NodeHeaders, Response as NodeResponse, Request as NodeRequest } from 'node-fetch';
3
- /** 生成 fetch */
4
- function makeFetch() {
5
- const hasProxy = !!process.env['HTTP_PROXY'] ||
6
- !!process.env['http_proxy'] ||
7
- !!process.env['HTTPS_PROXY'] ||
8
- !!process.env['https_proxy'] ||
9
- !!process.env['ALL_PROXY'] ||
10
- !!process.env['all_proxy'];
11
- if (hasProxy) {
12
- const agent = new ProxyAgent();
13
- return [
14
- function fetch(url, init) {
15
- return nodeFetch(url, { ...init, agent });
16
- },
17
- agent,
18
- ];
19
- }
20
- else {
21
- return [nodeFetch, undefined];
22
- }
23
- }
24
- export const [fetch, agent] = makeFetch();
25
- export const Headers = NodeHeaders;
26
- export const Response = NodeResponse;
27
- export const Request = NodeRequest;
28
- export default fetch;
1
+ import ProxyAgent from 'proxy-agent';
2
+ import nodeFetch, { Headers as NodeHeaders, Response as NodeResponse, Request as NodeRequest } from 'node-fetch';
3
+ /** 生成 fetch */
4
+ function makeFetch() {
5
+ const hasProxy = !!process.env['HTTP_PROXY'] ||
6
+ !!process.env['http_proxy'] ||
7
+ !!process.env['HTTPS_PROXY'] ||
8
+ !!process.env['https_proxy'] ||
9
+ !!process.env['ALL_PROXY'] ||
10
+ !!process.env['all_proxy'];
11
+ if (hasProxy) {
12
+ const agent = new ProxyAgent();
13
+ return [
14
+ function fetch(url, init) {
15
+ return nodeFetch(url, { ...init, agent });
16
+ },
17
+ agent,
18
+ ];
19
+ }
20
+ else {
21
+ return [nodeFetch, undefined];
22
+ }
23
+ }
24
+ export const [fetch, agent] = makeFetch();
25
+ export const Headers = NodeHeaders;
26
+ export const Response = NodeResponse;
27
+ export const Request = NodeRequest;
28
+ export default fetch;
29
29
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudpss/fetch",
3
- "version": "0.4.12",
3
+ "version": "0.4.13",
4
4
  "author": "CloudPSS",
5
5
  "license": "MIT",
6
6
  "type": "module",