@whatwg-node/node-fetch 0.4.4-alpha-20230613142519-c024d92 → 0.4.4-alpha-20230613143421-6ca77f9
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/cjs/Response.js +17 -16
- package/esm/Response.js +17 -16
- package/package.json +1 -1
- package/typings/Response.d.cts +1 -1
- package/typings/Response.d.ts +1 -1
package/cjs/Response.js
CHANGED
@@ -60,25 +60,26 @@ class PonyfillResponse extends Body_js_1.PonyfillBody {
|
|
60
60
|
});
|
61
61
|
}
|
62
62
|
static json(data, init) {
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
}
|
70
|
-
if (!init.headers.has('content-length')) {
|
71
|
-
init.headers.set('content-length', Buffer.byteLength(jsonStr).toString());
|
72
|
-
}
|
63
|
+
let bodyInit = JSON.stringify(data);
|
64
|
+
const resInit = init || {};
|
65
|
+
if (resInit.headers != null) {
|
66
|
+
resInit.headers = new Headers_js_1.PonyfillHeaders(resInit.headers);
|
67
|
+
if (!resInit.headers.has('content-type')) {
|
68
|
+
resInit.headers.set('content-type', JSON_CONTENT_TYPE);
|
73
69
|
}
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
['content-length', Buffer.byteLength(jsonStr).toString()],
|
78
|
-
];
|
70
|
+
if (!resInit.headers.has('content-length')) {
|
71
|
+
bodyInit = Buffer.from(bodyInit);
|
72
|
+
resInit.headers.set('content-length', bodyInit.byteLength.toString());
|
79
73
|
}
|
80
74
|
}
|
81
|
-
|
75
|
+
else {
|
76
|
+
bodyInit = Buffer.from(bodyInit);
|
77
|
+
resInit.headers = [
|
78
|
+
['content-type', JSON_CONTENT_TYPE],
|
79
|
+
['content-length', bodyInit.byteLength.toString()],
|
80
|
+
];
|
81
|
+
}
|
82
|
+
return new PonyfillResponse(bodyInit, init);
|
82
83
|
}
|
83
84
|
}
|
84
85
|
exports.PonyfillResponse = PonyfillResponse;
|
package/esm/Response.js
CHANGED
@@ -57,24 +57,25 @@ export class PonyfillResponse extends PonyfillBody {
|
|
57
57
|
});
|
58
58
|
}
|
59
59
|
static json(data, init) {
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
}
|
67
|
-
if (!init.headers.has('content-length')) {
|
68
|
-
init.headers.set('content-length', Buffer.byteLength(jsonStr).toString());
|
69
|
-
}
|
60
|
+
let bodyInit = JSON.stringify(data);
|
61
|
+
const resInit = init || {};
|
62
|
+
if (resInit.headers != null) {
|
63
|
+
resInit.headers = new PonyfillHeaders(resInit.headers);
|
64
|
+
if (!resInit.headers.has('content-type')) {
|
65
|
+
resInit.headers.set('content-type', JSON_CONTENT_TYPE);
|
70
66
|
}
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
['content-length', Buffer.byteLength(jsonStr).toString()],
|
75
|
-
];
|
67
|
+
if (!resInit.headers.has('content-length')) {
|
68
|
+
bodyInit = Buffer.from(bodyInit);
|
69
|
+
resInit.headers.set('content-length', bodyInit.byteLength.toString());
|
76
70
|
}
|
77
71
|
}
|
78
|
-
|
72
|
+
else {
|
73
|
+
bodyInit = Buffer.from(bodyInit);
|
74
|
+
resInit.headers = [
|
75
|
+
['content-type', JSON_CONTENT_TYPE],
|
76
|
+
['content-length', bodyInit.byteLength.toString()],
|
77
|
+
];
|
78
|
+
}
|
79
|
+
return new PonyfillResponse(bodyInit, init);
|
79
80
|
}
|
80
81
|
}
|
package/package.json
CHANGED
package/typings/Response.d.cts
CHANGED
@@ -18,5 +18,5 @@ export declare class PonyfillResponse<TJSON = any> extends PonyfillBody<TJSON> i
|
|
18
18
|
clone(): PonyfillResponse<any>;
|
19
19
|
static error(): PonyfillResponse<any>;
|
20
20
|
static redirect(url: string, status?: number): PonyfillResponse<any>;
|
21
|
-
static json<T = any>(data: T, init?:
|
21
|
+
static json<T = any>(data: T, init?: ResponsePonyfilInit): PonyfillResponse<T>;
|
22
22
|
}
|
package/typings/Response.d.ts
CHANGED
@@ -18,5 +18,5 @@ export declare class PonyfillResponse<TJSON = any> extends PonyfillBody<TJSON> i
|
|
18
18
|
clone(): PonyfillResponse<any>;
|
19
19
|
static error(): PonyfillResponse<any>;
|
20
20
|
static redirect(url: string, status?: number): PonyfillResponse<any>;
|
21
|
-
static json<T = any>(data: T, init?:
|
21
|
+
static json<T = any>(data: T, init?: ResponsePonyfilInit): PonyfillResponse<T>;
|
22
22
|
}
|