@whatwg-node/node-fetch 0.0.1-alpha-20230109165738-8edf269 → 0.0.1-alpha-20230117084928-a052439
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.
- package/Body.d.ts +2 -2
- package/Request.d.ts +1 -1
- package/Response.d.ts +6 -5
- package/fetch.d.ts +1 -1
- package/index.js +4 -4
- package/index.mjs +4 -4
- package/package.json +1 -1
package/Body.d.ts
CHANGED
@@ -16,7 +16,7 @@ export interface FormDataLimits {
|
|
16
16
|
export interface PonyfillBodyOptions {
|
17
17
|
formDataLimits?: FormDataLimits;
|
18
18
|
}
|
19
|
-
export declare class PonyfillBody implements Body {
|
19
|
+
export declare class PonyfillBody<TJSON = any> implements Body {
|
20
20
|
private bodyInit;
|
21
21
|
private options;
|
22
22
|
bodyUsed: boolean;
|
@@ -31,6 +31,6 @@ export declare class PonyfillBody implements Body {
|
|
31
31
|
formData(opts?: {
|
32
32
|
formDataLimits: FormDataLimits;
|
33
33
|
}): Promise<PonyfillFormData>;
|
34
|
-
json(): Promise<
|
34
|
+
json(): Promise<TJSON>;
|
35
35
|
text(): Promise<string>;
|
36
36
|
}
|
package/Request.d.ts
CHANGED
@@ -4,7 +4,7 @@ export type RequestPonyfillInit = PonyfillBodyOptions & Omit<RequestInit, 'body'
|
|
4
4
|
body?: BodyPonyfillInit | null;
|
5
5
|
headers?: PonyfillHeadersInit;
|
6
6
|
};
|
7
|
-
export declare class PonyfillRequest extends PonyfillBody implements Request {
|
7
|
+
export declare class PonyfillRequest<TJSON = any> extends PonyfillBody<TJSON> implements Request {
|
8
8
|
constructor(input: RequestInfo | URL, options?: RequestPonyfillInit);
|
9
9
|
cache: RequestCache;
|
10
10
|
credentials: RequestCredentials;
|
package/Response.d.ts
CHANGED
@@ -4,8 +4,9 @@ export type ResponsePonyfilInit = PonyfillBodyOptions & Omit<ResponseInit, 'head
|
|
4
4
|
url?: string;
|
5
5
|
redirected?: boolean;
|
6
6
|
headers?: PonyfillHeadersInit;
|
7
|
+
type?: ResponseType;
|
7
8
|
};
|
8
|
-
export declare class PonyfillResponse extends PonyfillBody implements Response {
|
9
|
+
export declare class PonyfillResponse<TJSON = any> extends PonyfillBody<TJSON> implements Response {
|
9
10
|
constructor(body?: BodyPonyfillInit | null, init?: ResponsePonyfilInit);
|
10
11
|
headers: Headers;
|
11
12
|
get ok(): boolean;
|
@@ -14,8 +15,8 @@ export declare class PonyfillResponse extends PonyfillBody implements Response {
|
|
14
15
|
url: string;
|
15
16
|
redirected: boolean;
|
16
17
|
type: ResponseType;
|
17
|
-
clone(): PonyfillResponse
|
18
|
-
static error(): PonyfillResponse
|
19
|
-
static redirect(url: string, status?: number): PonyfillResponse
|
20
|
-
static json(data:
|
18
|
+
clone(): PonyfillResponse<any>;
|
19
|
+
static error(): PonyfillResponse<any>;
|
20
|
+
static redirect(url: string, status?: number): PonyfillResponse<any>;
|
21
|
+
static json<T = any>(data: T, init?: RequestInit): PonyfillResponse<T>;
|
21
22
|
}
|
package/fetch.d.ts
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
import { PonyfillRequest, RequestPonyfillInit } from './Request';
|
2
2
|
import { PonyfillResponse } from './Response';
|
3
|
-
export declare
|
3
|
+
export declare function fetchPonyfill<TResponseJSON = any, TRequestJSON = any>(info: string | PonyfillRequest<TRequestJSON> | URL, init?: RequestPonyfillInit): Promise<PonyfillResponse<TResponseJSON>>;
|
package/index.js
CHANGED
@@ -697,6 +697,7 @@ class PonyfillResponse extends PonyfillBody {
|
|
697
697
|
this.statusText = init.statusText || 'OK';
|
698
698
|
this.url = init.url || '';
|
699
699
|
this.redirected = init.redirected || false;
|
700
|
+
this.type = init.type || 'default';
|
700
701
|
}
|
701
702
|
}
|
702
703
|
get ok() {
|
@@ -706,11 +707,10 @@ class PonyfillResponse extends PonyfillBody {
|
|
706
707
|
return new PonyfillResponse(this.body, this);
|
707
708
|
}
|
708
709
|
static error() {
|
709
|
-
|
710
|
+
return new PonyfillResponse(null, {
|
710
711
|
status: 500,
|
711
712
|
statusText: 'Internal Server Error',
|
712
713
|
});
|
713
|
-
return response;
|
714
714
|
}
|
715
715
|
static redirect(url, status = 301) {
|
716
716
|
if (status < 300 || status > 399) {
|
@@ -759,7 +759,7 @@ function getRequestFnForProtocol(protocol) {
|
|
759
759
|
}
|
760
760
|
throw new Error(`Unsupported protocol: ${protocol}`);
|
761
761
|
}
|
762
|
-
|
762
|
+
function fetchPonyfill(info, init) {
|
763
763
|
if (typeof info === 'string' || info instanceof URL) {
|
764
764
|
const ponyfillRequest = new PonyfillRequest(info, init);
|
765
765
|
return fetchPonyfill(ponyfillRequest);
|
@@ -830,7 +830,7 @@ const fetchPonyfill = (info, init) => {
|
|
830
830
|
reject(e);
|
831
831
|
}
|
832
832
|
});
|
833
|
-
}
|
833
|
+
}
|
834
834
|
|
835
835
|
class PonyfillTextEncoder {
|
836
836
|
constructor(encoding = 'utf-8') {
|
package/index.mjs
CHANGED
@@ -691,6 +691,7 @@ class PonyfillResponse extends PonyfillBody {
|
|
691
691
|
this.statusText = init.statusText || 'OK';
|
692
692
|
this.url = init.url || '';
|
693
693
|
this.redirected = init.redirected || false;
|
694
|
+
this.type = init.type || 'default';
|
694
695
|
}
|
695
696
|
}
|
696
697
|
get ok() {
|
@@ -700,11 +701,10 @@ class PonyfillResponse extends PonyfillBody {
|
|
700
701
|
return new PonyfillResponse(this.body, this);
|
701
702
|
}
|
702
703
|
static error() {
|
703
|
-
|
704
|
+
return new PonyfillResponse(null, {
|
704
705
|
status: 500,
|
705
706
|
statusText: 'Internal Server Error',
|
706
707
|
});
|
707
|
-
return response;
|
708
708
|
}
|
709
709
|
static redirect(url, status = 301) {
|
710
710
|
if (status < 300 || status > 399) {
|
@@ -753,7 +753,7 @@ function getRequestFnForProtocol(protocol) {
|
|
753
753
|
}
|
754
754
|
throw new Error(`Unsupported protocol: ${protocol}`);
|
755
755
|
}
|
756
|
-
|
756
|
+
function fetchPonyfill(info, init) {
|
757
757
|
if (typeof info === 'string' || info instanceof URL) {
|
758
758
|
const ponyfillRequest = new PonyfillRequest(info, init);
|
759
759
|
return fetchPonyfill(ponyfillRequest);
|
@@ -824,7 +824,7 @@ const fetchPonyfill = (info, init) => {
|
|
824
824
|
reject(e);
|
825
825
|
}
|
826
826
|
});
|
827
|
-
}
|
827
|
+
}
|
828
828
|
|
829
829
|
class PonyfillTextEncoder {
|
830
830
|
constructor(encoding = 'utf-8') {
|
package/package.json
CHANGED