@whatwg-node/node-fetch 0.5.18-alpha-20240726153005-ce5d304c2d2f79f6b44b7fc5a6ac4ec231b76090 → 0.5.18

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/Blob.js CHANGED
@@ -53,7 +53,7 @@ function isArrayBuffer(obj) {
53
53
  // Will be removed after v14 reaches EOL
54
54
  // Needed because v14 doesn't have .stream() implemented
55
55
  class PonyfillBlob {
56
- constructor(blobParts, options) {
56
+ constructor(blobParts = [], options) {
57
57
  this.blobParts = blobParts;
58
58
  this._size = null;
59
59
  this._buffer = null;
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- var _a;
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.PonyfillReadableStream = void 0;
5
4
  const stream_1 = require("stream");
@@ -53,7 +52,6 @@ function isReadableStream(obj) {
53
52
  class PonyfillReadableStream {
54
53
  constructor(underlyingSource) {
55
54
  this.locked = false;
56
- this[_a] = 'ReadableStream';
57
55
  if (underlyingSource instanceof PonyfillReadableStream && underlyingSource.readable != null) {
58
56
  this.readable = underlyingSource.readable;
59
57
  }
@@ -186,7 +184,6 @@ class PonyfillReadableStream {
186
184
  }
187
185
  }
188
186
  exports.PonyfillReadableStream = PonyfillReadableStream;
189
- _a = Symbol.toStringTag;
190
187
  function isPonyfillWritableStream(obj) {
191
188
  return obj?.writable != null;
192
189
  }
package/cjs/Response.js CHANGED
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- var _a;
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.PonyfillResponse = void 0;
5
4
  const http_1 = require("http");
@@ -9,7 +8,6 @@ const JSON_CONTENT_TYPE = 'application/json; charset=utf-8';
9
8
  class PonyfillResponse extends Body_js_1.PonyfillBody {
10
9
  constructor(body, init) {
11
10
  super(body || null, init);
12
- this[_a] = 'Response';
13
11
  this.headers =
14
12
  init?.headers && (0, Headers_js_1.isHeadersLike)(init.headers)
15
13
  ? init.headers
@@ -73,4 +71,3 @@ class PonyfillResponse extends Body_js_1.PonyfillBody {
73
71
  }
74
72
  }
75
73
  exports.PonyfillResponse = PonyfillResponse;
76
- _a = Symbol.toStringTag;
package/cjs/index.js CHANGED
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DecompressionStream = exports.CompressionStream = exports.TransformStream = exports.WritableStream = exports.URLSearchParams = exports.URL = exports.btoa = exports.TextDecoder = exports.TextEncoder = exports.Blob = exports.FormData = exports.File = exports.ReadableStream = exports.Response = exports.Request = exports.Body = exports.Headers = exports.fetch = exports.patchReadableFromWeb = void 0;
4
- var utils_js_1 = require("./utils.js");
5
- Object.defineProperty(exports, "patchReadableFromWeb", { enumerable: true, get: function () { return utils_js_1.patchReadableFromWeb; } });
3
+ exports.DecompressionStream = exports.CompressionStream = exports.TransformStream = exports.WritableStream = exports.URLSearchParams = exports.URL = exports.btoa = exports.TextDecoder = exports.TextEncoder = exports.Blob = exports.FormData = exports.File = exports.ReadableStream = exports.Response = exports.Request = exports.Body = exports.Headers = exports.fetch = void 0;
6
4
  var fetch_js_1 = require("./fetch.js");
7
5
  Object.defineProperty(exports, "fetch", { enumerable: true, get: function () { return fetch_js_1.fetchPonyfill; } });
8
6
  var Headers_js_1 = require("./Headers.js");
package/cjs/utils.js CHANGED
@@ -1,50 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.patchReadableFromWeb = patchReadableFromWeb;
4
3
  exports.getHeadersObj = getHeadersObj;
5
4
  exports.defaultHeadersSerializer = defaultHeadersSerializer;
6
5
  exports.fakePromise = fakePromise;
7
6
  exports.isArrayBufferView = isArrayBufferView;
8
7
  exports.isNodeReadable = isNodeReadable;
9
- const stream_1 = require("stream");
10
8
  function isHeadersInstance(obj) {
11
9
  return obj?.forEach != null;
12
10
  }
13
- function patchReadableFromWeb() {
14
- try {
15
- const originalReadableFromWeb = stream_1.Readable.fromWeb;
16
- // eslint-disable-next-line no-inner-declarations
17
- function ReadableFromWebPatchedByWhatWgNode(stream) {
18
- if (stream.readable instanceof stream_1.Readable) {
19
- return stream.readable;
20
- }
21
- return originalReadableFromWeb(stream);
22
- }
23
- if (originalReadableFromWeb.name !== 'ReadableFromWebPatchedByWhatWgNode') {
24
- if (typeof jest === 'object' &&
25
- typeof beforeEach === 'function' &&
26
- typeof afterEach === 'function') {
27
- // To relax jest, we should remove the patch after each test
28
- beforeEach(() => {
29
- if (stream_1.Readable.fromWeb.name !== 'ReadableFromWebPatchedByWhatWgNode') {
30
- stream_1.Readable.fromWeb = ReadableFromWebPatchedByWhatWgNode;
31
- }
32
- });
33
- afterEach(() => {
34
- if (stream_1.Readable.fromWeb.name === 'ReadableFromWebPatchedByWhatWgNode') {
35
- stream_1.Readable.fromWeb = originalReadableFromWeb;
36
- }
37
- });
38
- }
39
- else {
40
- stream_1.Readable.fromWeb = ReadableFromWebPatchedByWhatWgNode;
41
- }
42
- }
43
- }
44
- catch (e) {
45
- console.warn('Could not patch Readable.fromWeb, so this might break Readable.fromWeb usage with the whatwg-node and the integrations like Fastify', e);
46
- }
47
- }
48
11
  function getHeadersObj(headers) {
49
12
  if (headers == null || !isHeadersInstance(headers)) {
50
13
  return headers;
package/esm/Blob.js CHANGED
@@ -42,7 +42,7 @@ export function isArrayBuffer(obj) {
42
42
  // Will be removed after v14 reaches EOL
43
43
  // Needed because v14 doesn't have .stream() implemented
44
44
  export class PonyfillBlob {
45
- constructor(blobParts, options) {
45
+ constructor(blobParts = [], options) {
46
46
  this.blobParts = blobParts;
47
47
  this._size = null;
48
48
  this._buffer = null;
@@ -1,4 +1,3 @@
1
- var _a;
2
1
  import { Readable } from 'stream';
3
2
  function createController(desiredSize, readable) {
4
3
  let chunks = [];
@@ -50,7 +49,6 @@ function isReadableStream(obj) {
50
49
  export class PonyfillReadableStream {
51
50
  constructor(underlyingSource) {
52
51
  this.locked = false;
53
- this[_a] = 'ReadableStream';
54
52
  if (underlyingSource instanceof PonyfillReadableStream && underlyingSource.readable != null) {
55
53
  this.readable = underlyingSource.readable;
56
54
  }
@@ -182,7 +180,6 @@ export class PonyfillReadableStream {
182
180
  return isReadableStream(instance);
183
181
  }
184
182
  }
185
- _a = Symbol.toStringTag;
186
183
  function isPonyfillWritableStream(obj) {
187
184
  return obj?.writable != null;
188
185
  }
package/esm/Response.js CHANGED
@@ -1,4 +1,3 @@
1
- var _a;
2
1
  import { STATUS_CODES } from 'http';
3
2
  import { PonyfillBody } from './Body.js';
4
3
  import { isHeadersLike, PonyfillHeaders } from './Headers.js';
@@ -6,7 +5,6 @@ const JSON_CONTENT_TYPE = 'application/json; charset=utf-8';
6
5
  export class PonyfillResponse extends PonyfillBody {
7
6
  constructor(body, init) {
8
7
  super(body || null, init);
9
- this[_a] = 'Response';
10
8
  this.headers =
11
9
  init?.headers && isHeadersLike(init.headers)
12
10
  ? init.headers
@@ -69,4 +67,3 @@ export class PonyfillResponse extends PonyfillBody {
69
67
  return new PonyfillResponse(JSON.stringify(data), init);
70
68
  }
71
69
  }
72
- _a = Symbol.toStringTag;
package/esm/index.js CHANGED
@@ -1,4 +1,3 @@
1
- export { patchReadableFromWeb } from './utils.js';
2
1
  export { fetchPonyfill as fetch } from './fetch.js';
3
2
  export { PonyfillHeaders as Headers } from './Headers.js';
4
3
  export { PonyfillBody as Body } from './Body.js';
package/esm/utils.js CHANGED
@@ -1,42 +1,6 @@
1
- import { Readable } from 'stream';
2
1
  function isHeadersInstance(obj) {
3
2
  return obj?.forEach != null;
4
3
  }
5
- export function patchReadableFromWeb() {
6
- try {
7
- const originalReadableFromWeb = Readable.fromWeb;
8
- // eslint-disable-next-line no-inner-declarations
9
- function ReadableFromWebPatchedByWhatWgNode(stream) {
10
- if (stream.readable instanceof Readable) {
11
- return stream.readable;
12
- }
13
- return originalReadableFromWeb(stream);
14
- }
15
- if (originalReadableFromWeb.name !== 'ReadableFromWebPatchedByWhatWgNode') {
16
- if (typeof jest === 'object' &&
17
- typeof beforeEach === 'function' &&
18
- typeof afterEach === 'function') {
19
- // To relax jest, we should remove the patch after each test
20
- beforeEach(() => {
21
- if (Readable.fromWeb.name !== 'ReadableFromWebPatchedByWhatWgNode') {
22
- Readable.fromWeb = ReadableFromWebPatchedByWhatWgNode;
23
- }
24
- });
25
- afterEach(() => {
26
- if (Readable.fromWeb.name === 'ReadableFromWebPatchedByWhatWgNode') {
27
- Readable.fromWeb = originalReadableFromWeb;
28
- }
29
- });
30
- }
31
- else {
32
- Readable.fromWeb = ReadableFromWebPatchedByWhatWgNode;
33
- }
34
- }
35
- }
36
- catch (e) {
37
- console.warn('Could not patch Readable.fromWeb, so this might break Readable.fromWeb usage with the whatwg-node and the integrations like Fastify', e);
38
- }
39
- }
40
4
  export function getHeadersObj(headers) {
41
5
  if (headers == null || !isHeadersInstance(headers)) {
42
6
  return headers;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whatwg-node/node-fetch",
3
- "version": "0.5.18-alpha-20240726153005-ce5d304c2d2f79f6b44b7fc5a6ac4ec231b76090",
3
+ "version": "0.5.18",
4
4
  "description": "Fetch API implementation for Node",
5
5
  "sideEffects": false,
6
6
  "dependencies": {
@@ -39,7 +39,7 @@ export declare class PonyfillBlob implements Blob {
39
39
  type: string;
40
40
  private encoding;
41
41
  private _size;
42
- constructor(blobParts: BlobPart[], options?: BlobOptions);
42
+ constructor(blobParts?: BlobPart[], options?: BlobOptions);
43
43
  _buffer: Buffer | null;
44
44
  buffer(): Promise<Buffer>;
45
45
  arrayBuffer(): Promise<ArrayBuffer>;
package/typings/Blob.d.ts CHANGED
@@ -39,7 +39,7 @@ export declare class PonyfillBlob implements Blob {
39
39
  type: string;
40
40
  private encoding;
41
41
  private _size;
42
- constructor(blobParts: BlobPart[], options?: BlobOptions);
42
+ constructor(blobParts?: BlobPart[], options?: BlobOptions);
43
43
  _buffer: Buffer | null;
44
44
  buffer(): Promise<Buffer>;
45
45
  arrayBuffer(): Promise<ArrayBuffer>;
@@ -16,5 +16,4 @@ export declare class PonyfillReadableStream<T> implements ReadableStream<T> {
16
16
  readable: ReadableStream<T2>;
17
17
  }): ReadableStream<T2>;
18
18
  static [Symbol.hasInstance](instance: unknown): instance is PonyfillReadableStream<unknown>;
19
- [Symbol.toStringTag]: string;
20
19
  }
@@ -16,5 +16,4 @@ export declare class PonyfillReadableStream<T> implements ReadableStream<T> {
16
16
  readable: ReadableStream<T2>;
17
17
  }): ReadableStream<T2>;
18
18
  static [Symbol.hasInstance](instance: unknown): instance is PonyfillReadableStream<unknown>;
19
- [Symbol.toStringTag]: string;
20
19
  }
@@ -19,5 +19,4 @@ export declare class PonyfillResponse<TJSON = any> extends PonyfillBody<TJSON> i
19
19
  static error(): PonyfillResponse<any>;
20
20
  static redirect(url: string, status?: number): PonyfillResponse<any>;
21
21
  static json<T = any>(data: T, init?: ResponsePonyfilInit): PonyfillResponse<T>;
22
- [Symbol.toStringTag]: string;
23
22
  }
@@ -19,5 +19,4 @@ export declare class PonyfillResponse<TJSON = any> extends PonyfillBody<TJSON> i
19
19
  static error(): PonyfillResponse<any>;
20
20
  static redirect(url: string, status?: number): PonyfillResponse<any>;
21
21
  static json<T = any>(data: T, init?: ResponsePonyfilInit): PonyfillResponse<T>;
22
- [Symbol.toStringTag]: string;
23
22
  }
@@ -1,4 +1,3 @@
1
- export { patchReadableFromWeb } from './utils.cjs';
2
1
  export { fetchPonyfill as fetch } from './fetch.cjs';
3
2
  export { PonyfillHeaders as Headers } from './Headers.cjs';
4
3
  export { PonyfillBody as Body } from './Body.cjs';
@@ -1,4 +1,3 @@
1
- export { patchReadableFromWeb } from './utils.js';
2
1
  export { fetchPonyfill as fetch } from './fetch.js';
3
2
  export { PonyfillHeaders as Headers } from './Headers.js';
4
3
  export { PonyfillBody as Body } from './Body.js';
@@ -1,5 +1,4 @@
1
1
  import { Readable } from 'stream';
2
- export declare function patchReadableFromWeb(): void;
3
2
  export declare function getHeadersObj(headers: Headers): Record<string, string>;
4
3
  export declare function defaultHeadersSerializer(headers: Headers, onContentLength?: (value: string) => void): string[];
5
4
  export declare function fakePromise<T>(value: T): Promise<T>;
@@ -1,5 +1,4 @@
1
1
  import { Readable } from 'stream';
2
- export declare function patchReadableFromWeb(): void;
3
2
  export declare function getHeadersObj(headers: Headers): Record<string, string>;
4
3
  export declare function defaultHeadersSerializer(headers: Headers, onContentLength?: (value: string) => void): string[];
5
4
  export declare function fakePromise<T>(value: T): Promise<T>;