@whatwg-node/node-fetch 0.7.20-alpha-20250515123934-037460f929f788c2d3902d4d68aca61757f84761 → 0.7.20-alpha-20250515124736-4343870fcd826017d2a224bb7cd95417a1a89df3

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/Headers.js CHANGED
@@ -4,6 +4,7 @@ exports.PonyfillHeaders = void 0;
4
4
  exports.isHeadersLike = isHeadersLike;
5
5
  const node_util_1 = require("node:util");
6
6
  const IteratorObject_js_1 = require("./IteratorObject.js");
7
+ const utils_js_1 = require("./utils.js");
7
8
  function isHeadersLike(headers) {
8
9
  return headers?.get && headers?.forEach;
9
10
  }
@@ -30,7 +31,7 @@ class PonyfillHeaders {
30
31
  if (this.headersInit == null) {
31
32
  return null;
32
33
  }
33
- if (Array.isArray(this.headersInit)) {
34
+ if ((0, utils_js_1.isArray)(this.headersInit)) {
34
35
  const found = this.headersInit.filter(([headerKey]) => headerKey.toLowerCase() === normalized);
35
36
  if (found.length === 0) {
36
37
  return null;
@@ -68,7 +69,7 @@ class PonyfillHeaders {
68
69
  if (!this._map) {
69
70
  this._setCookies = [];
70
71
  if (this.headersInit != null) {
71
- if (Array.isArray(this.headersInit)) {
72
+ if ((0, utils_js_1.isArray)(this.headersInit)) {
72
73
  this._map = new Map();
73
74
  for (const [key, value] of this.headersInit) {
74
75
  const normalizedKey = key.toLowerCase();
@@ -147,7 +148,7 @@ class PonyfillHeaders {
147
148
  return;
148
149
  }
149
150
  if (this.headersInit != null) {
150
- if (Array.isArray(this.headersInit)) {
151
+ if ((0, utils_js_1.isArray)(this.headersInit)) {
151
152
  const found = this.headersInit.find(([headerKey]) => headerKey.toLowerCase() === key);
152
153
  if (found) {
153
154
  found[1] = value;
@@ -182,7 +183,7 @@ class PonyfillHeaders {
182
183
  });
183
184
  if (!this._map) {
184
185
  if (this.headersInit) {
185
- if (Array.isArray(this.headersInit)) {
186
+ if ((0, utils_js_1.isArray)(this.headersInit)) {
186
187
  this.headersInit.forEach(([key, value]) => {
187
188
  callback(value, key, this);
188
189
  });
@@ -210,7 +211,7 @@ class PonyfillHeaders {
210
211
  }
211
212
  if (!this._map) {
212
213
  if (this.headersInit) {
213
- if (Array.isArray(this.headersInit)) {
214
+ if ((0, utils_js_1.isArray)(this.headersInit)) {
214
215
  yield* this.headersInit.map(([key]) => key)[Symbol.iterator]();
215
216
  return;
216
217
  }
@@ -233,7 +234,7 @@ class PonyfillHeaders {
233
234
  }
234
235
  if (!this._map) {
235
236
  if (this.headersInit) {
236
- if (Array.isArray(this.headersInit)) {
237
+ if ((0, utils_js_1.isArray)(this.headersInit)) {
237
238
  yield* this.headersInit.map(([, value]) => value)[Symbol.iterator]();
238
239
  return;
239
240
  }
@@ -256,7 +257,7 @@ class PonyfillHeaders {
256
257
  }
257
258
  if (!this._map) {
258
259
  if (this.headersInit) {
259
- if (Array.isArray(this.headersInit)) {
260
+ if ((0, utils_js_1.isArray)(this.headersInit)) {
260
261
  yield* this.headersInit;
261
262
  return;
262
263
  }
package/cjs/Response.js CHANGED
@@ -4,6 +4,7 @@ exports.PonyfillResponse = void 0;
4
4
  const node_http_1 = require("node:http");
5
5
  const Body_js_1 = require("./Body.js");
6
6
  const Headers_js_1 = require("./Headers.js");
7
+ const utils_js_1 = require("./utils.js");
7
8
  const JSON_CONTENT_TYPE = 'application/json; charset=utf-8';
8
9
  class PonyfillResponse extends Body_js_1.PonyfillBody {
9
10
  headers;
@@ -66,7 +67,7 @@ class PonyfillResponse extends Body_js_1.PonyfillBody {
66
67
  init.headers.set('content-type', JSON_CONTENT_TYPE);
67
68
  }
68
69
  }
69
- else if (Array.isArray(init.headers)) {
70
+ else if ((0, utils_js_1.isArray)(init.headers)) {
70
71
  if (!init.headers.some(([key]) => key.toLowerCase() === 'content-type')) {
71
72
  init.headers.push(['content-type', JSON_CONTENT_TYPE]);
72
73
  }
package/cjs/utils.js CHANGED
@@ -10,6 +10,7 @@ exports.shouldRedirect = shouldRedirect;
10
10
  exports.wrapIncomingMessageWithPassthrough = wrapIncomingMessageWithPassthrough;
11
11
  exports.endStream = endStream;
12
12
  exports.safeWrite = safeWrite;
13
+ exports.isArray = isArray;
13
14
  const node_events_1 = require("node:events");
14
15
  const node_stream_1 = require("node:stream");
15
16
  const promises_1 = require("node:stream/promises");
@@ -73,3 +74,6 @@ function safeWrite(chunk, stream, signal) {
73
74
  });
74
75
  }
75
76
  }
77
+ function isArray(value) {
78
+ return value?.length && value?.map && value?.slice && value?.splice;
79
+ }
package/esm/Headers.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { inspect } from 'node:util';
2
2
  import { PonyfillIteratorObject } from './IteratorObject.js';
3
+ import { isArray } from './utils.js';
3
4
  export function isHeadersLike(headers) {
4
5
  return headers?.get && headers?.forEach;
5
6
  }
@@ -26,7 +27,7 @@ export class PonyfillHeaders {
26
27
  if (this.headersInit == null) {
27
28
  return null;
28
29
  }
29
- if (Array.isArray(this.headersInit)) {
30
+ if (isArray(this.headersInit)) {
30
31
  const found = this.headersInit.filter(([headerKey]) => headerKey.toLowerCase() === normalized);
31
32
  if (found.length === 0) {
32
33
  return null;
@@ -64,7 +65,7 @@ export class PonyfillHeaders {
64
65
  if (!this._map) {
65
66
  this._setCookies = [];
66
67
  if (this.headersInit != null) {
67
- if (Array.isArray(this.headersInit)) {
68
+ if (isArray(this.headersInit)) {
68
69
  this._map = new Map();
69
70
  for (const [key, value] of this.headersInit) {
70
71
  const normalizedKey = key.toLowerCase();
@@ -143,7 +144,7 @@ export class PonyfillHeaders {
143
144
  return;
144
145
  }
145
146
  if (this.headersInit != null) {
146
- if (Array.isArray(this.headersInit)) {
147
+ if (isArray(this.headersInit)) {
147
148
  const found = this.headersInit.find(([headerKey]) => headerKey.toLowerCase() === key);
148
149
  if (found) {
149
150
  found[1] = value;
@@ -178,7 +179,7 @@ export class PonyfillHeaders {
178
179
  });
179
180
  if (!this._map) {
180
181
  if (this.headersInit) {
181
- if (Array.isArray(this.headersInit)) {
182
+ if (isArray(this.headersInit)) {
182
183
  this.headersInit.forEach(([key, value]) => {
183
184
  callback(value, key, this);
184
185
  });
@@ -206,7 +207,7 @@ export class PonyfillHeaders {
206
207
  }
207
208
  if (!this._map) {
208
209
  if (this.headersInit) {
209
- if (Array.isArray(this.headersInit)) {
210
+ if (isArray(this.headersInit)) {
210
211
  yield* this.headersInit.map(([key]) => key)[Symbol.iterator]();
211
212
  return;
212
213
  }
@@ -229,7 +230,7 @@ export class PonyfillHeaders {
229
230
  }
230
231
  if (!this._map) {
231
232
  if (this.headersInit) {
232
- if (Array.isArray(this.headersInit)) {
233
+ if (isArray(this.headersInit)) {
233
234
  yield* this.headersInit.map(([, value]) => value)[Symbol.iterator]();
234
235
  return;
235
236
  }
@@ -252,7 +253,7 @@ export class PonyfillHeaders {
252
253
  }
253
254
  if (!this._map) {
254
255
  if (this.headersInit) {
255
- if (Array.isArray(this.headersInit)) {
256
+ if (isArray(this.headersInit)) {
256
257
  yield* this.headersInit;
257
258
  return;
258
259
  }
package/esm/Response.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { STATUS_CODES } from 'node:http';
2
2
  import { PonyfillBody } from './Body.js';
3
3
  import { isHeadersLike, PonyfillHeaders } from './Headers.js';
4
+ import { isArray } from './utils.js';
4
5
  const JSON_CONTENT_TYPE = 'application/json; charset=utf-8';
5
6
  export class PonyfillResponse extends PonyfillBody {
6
7
  headers;
@@ -63,7 +64,7 @@ export class PonyfillResponse extends PonyfillBody {
63
64
  init.headers.set('content-type', JSON_CONTENT_TYPE);
64
65
  }
65
66
  }
66
- else if (Array.isArray(init.headers)) {
67
+ else if (isArray(init.headers)) {
67
68
  if (!init.headers.some(([key]) => key.toLowerCase() === 'content-type')) {
68
69
  init.headers.push(['content-type', JSON_CONTENT_TYPE]);
69
70
  }
package/esm/utils.js CHANGED
@@ -60,3 +60,6 @@ export function safeWrite(chunk, stream, signal) {
60
60
  });
61
61
  }
62
62
  }
63
+ export function isArray(value) {
64
+ return value?.length && value?.map && value?.slice && value?.splice;
65
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whatwg-node/node-fetch",
3
- "version": "0.7.20-alpha-20250515123934-037460f929f788c2d3902d4d68aca61757f84761",
3
+ "version": "0.7.20-alpha-20250515124736-4343870fcd826017d2a224bb7cd95417a1a89df3",
4
4
  "description": "Fetch API implementation for Node",
5
5
  "sideEffects": false,
6
6
  "dependencies": {
@@ -17,3 +17,4 @@ export declare function endStream(stream: {
17
17
  end: () => void;
18
18
  }): void;
19
19
  export declare function safeWrite(chunk: any, stream: Writable, signal?: AbortSignal | undefined): Promise<any> | undefined;
20
+ export declare function isArray<T>(value: any): value is T[];
@@ -17,3 +17,4 @@ export declare function endStream(stream: {
17
17
  end: () => void;
18
18
  }): void;
19
19
  export declare function safeWrite(chunk: any, stream: Writable, signal?: AbortSignal | undefined): Promise<any> | undefined;
20
+ export declare function isArray<T>(value: any): value is T[];