@whatwg-node/node-fetch 0.4.4-alpha-20230613143421-6ca77f9 → 0.4.4-alpha-20230613145642-e02eaf5

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 CHANGED
@@ -59,22 +59,21 @@ class PonyfillResponse extends Body_js_1.PonyfillBody {
59
59
  status,
60
60
  });
61
61
  }
62
- static json(data, init) {
62
+ static json(data, init = {}) {
63
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);
64
+ if (init.headers != null) {
65
+ init.headers = new Headers_js_1.PonyfillHeaders(init.headers);
66
+ if (!init.headers.has('content-type')) {
67
+ init.headers.set('content-type', JSON_CONTENT_TYPE);
69
68
  }
70
- if (!resInit.headers.has('content-length')) {
69
+ if (!init.headers.has('content-length')) {
71
70
  bodyInit = Buffer.from(bodyInit);
72
- resInit.headers.set('content-length', bodyInit.byteLength.toString());
71
+ init.headers.set('content-length', bodyInit.byteLength.toString());
73
72
  }
74
73
  }
75
74
  else {
76
75
  bodyInit = Buffer.from(bodyInit);
77
- resInit.headers = [
76
+ init.headers = [
78
77
  ['content-type', JSON_CONTENT_TYPE],
79
78
  ['content-length', bodyInit.byteLength.toString()],
80
79
  ];
package/esm/Response.js CHANGED
@@ -56,22 +56,21 @@ export class PonyfillResponse extends PonyfillBody {
56
56
  status,
57
57
  });
58
58
  }
59
- static json(data, init) {
59
+ static json(data, init = {}) {
60
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);
61
+ if (init.headers != null) {
62
+ init.headers = new PonyfillHeaders(init.headers);
63
+ if (!init.headers.has('content-type')) {
64
+ init.headers.set('content-type', JSON_CONTENT_TYPE);
66
65
  }
67
- if (!resInit.headers.has('content-length')) {
66
+ if (!init.headers.has('content-length')) {
68
67
  bodyInit = Buffer.from(bodyInit);
69
- resInit.headers.set('content-length', bodyInit.byteLength.toString());
68
+ init.headers.set('content-length', bodyInit.byteLength.toString());
70
69
  }
71
70
  }
72
71
  else {
73
72
  bodyInit = Buffer.from(bodyInit);
74
- resInit.headers = [
73
+ init.headers = [
75
74
  ['content-type', JSON_CONTENT_TYPE],
76
75
  ['content-length', bodyInit.byteLength.toString()],
77
76
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whatwg-node/node-fetch",
3
- "version": "0.4.4-alpha-20230613143421-6ca77f9",
3
+ "version": "0.4.4-alpha-20230613145642-e02eaf5",
4
4
  "description": "Fetch API implementation for Node",
5
5
  "sideEffects": false,
6
6
  "dependencies": {