Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@whatwg-node/node-fetch

Package Overview
Dependencies
Maintainers
1
Versions
509
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@whatwg-node/node-fetch - npm Package Compare versions

Comparing version 0.5.17 to 0.5.18-alpha-20240726144438-d85e825aca3e8ac57c7758d5ec88ed5c27358fcc

4

cjs/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
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;
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;
var utils_js_1 = require("./utils.js");
Object.defineProperty(exports, "patchReadableFromWeb", { enumerable: true, get: function () { return utils_js_1.patchReadableFromWeb; } });
var fetch_js_1 = require("./fetch.js");

@@ -5,0 +7,0 @@ Object.defineProperty(exports, "fetch", { enumerable: true, get: function () { return fetch_js_1.fetchPonyfill; } });

"use strict";
var _a;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -55,2 +56,3 @@ exports.PonyfillReadableStream = void 0;

this.locked = false;
this[_a] = 'ReadableStream';
if (underlyingSource instanceof PonyfillReadableStream && underlyingSource.readable != null) {

@@ -188,4 +190,5 @@ this.readable = underlyingSource.readable;

exports.PonyfillReadableStream = PonyfillReadableStream;
_a = Symbol.toStringTag;
function isPonyfillWritableStream(obj) {
return obj?.writable != null;
}
"use strict";
var _a;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -11,2 +12,3 @@ exports.PonyfillResponse = void 0;

super(body || null, init);
this[_a] = 'Response';
this.headers =

@@ -75,1 +77,2 @@ init?.headers && (0, Headers_js_1.isHeadersLike)(init.headers)

exports.PonyfillResponse = PonyfillResponse;
_a = Symbol.toStringTag;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.patchReadableFromWeb = patchReadableFromWeb;
exports.getHeadersObj = getHeadersObj;

@@ -8,5 +9,28 @@ exports.defaultHeadersSerializer = defaultHeadersSerializer;

exports.isNodeReadable = isNodeReadable;
const stream_1 = require("stream");
function isHeadersInstance(obj) {
return obj?.forEach != null;
}
function patchReadableFromWeb() {
try {
const originalReadableFromWeb = stream_1.Readable.fromWeb;
if (originalReadableFromWeb.name !== 'ReadableFromWebPatchedByWhatWgNode') {
stream_1.Readable.fromWeb = function ReadableFromWebPatchedByWhatWgNode(stream) {
if (stream.readable != null) {
return stream.readable;
}
return originalReadableFromWeb(stream);
};
if (typeof jest === 'object' && typeof afterEach === 'function') {
// To relax jest, we should remove the patch after each test
afterEach(() => {
stream_1.Readable.fromWeb = originalReadableFromWeb;
});
}
}
}
catch (e) {
console.warn('Could not patch Readable.fromWeb, so this might break Readable.fromWeb usage with the whatwg-node and the integrations like Fastify', e);
}
}
function getHeadersObj(headers) {

@@ -13,0 +37,0 @@ if (headers == null || !isHeadersInstance(headers)) {

@@ -0,1 +1,2 @@

export { patchReadableFromWeb } from './utils.js';
export { fetchPonyfill as fetch } from './fetch.js';

@@ -2,0 +3,0 @@ export { PonyfillHeaders as Headers } from './Headers.js';

@@ -0,1 +1,2 @@

var _a;
import { Readable } from 'stream';

@@ -52,2 +53,3 @@ function createController(desiredSize, readable) {

this.locked = false;
this[_a] = 'ReadableStream';
if (underlyingSource instanceof PonyfillReadableStream && underlyingSource.readable != null) {

@@ -184,4 +186,5 @@ this.readable = underlyingSource.readable;

}
_a = Symbol.toStringTag;
function isPonyfillWritableStream(obj) {
return obj?.writable != null;
}

@@ -0,1 +1,2 @@

var _a;
import { STATUS_CODES } from 'http';

@@ -8,2 +9,3 @@ import { PonyfillBody } from './Body.js';

super(body || null, init);
this[_a] = 'Response';
this.headers =

@@ -71,1 +73,2 @@ init?.headers && isHeadersLike(init.headers)

}
_a = Symbol.toStringTag;

@@ -0,4 +1,27 @@

import { Readable } from 'stream';
function isHeadersInstance(obj) {
return obj?.forEach != null;
}
export function patchReadableFromWeb() {
try {
const originalReadableFromWeb = Readable.fromWeb;
if (originalReadableFromWeb.name !== 'ReadableFromWebPatchedByWhatWgNode') {
Readable.fromWeb = function ReadableFromWebPatchedByWhatWgNode(stream) {
if (stream.readable != null) {
return stream.readable;
}
return originalReadableFromWeb(stream);
};
if (typeof jest === 'object' && typeof afterEach === 'function') {
// To relax jest, we should remove the patch after each test
afterEach(() => {
Readable.fromWeb = originalReadableFromWeb;
});
}
}
}
catch (e) {
console.warn('Could not patch Readable.fromWeb, so this might break Readable.fromWeb usage with the whatwg-node and the integrations like Fastify', e);
}
}
export function getHeadersObj(headers) {

@@ -5,0 +28,0 @@ if (headers == null || !isHeadersInstance(headers)) {

{
"name": "@whatwg-node/node-fetch",
"version": "0.5.17",
"version": "0.5.18-alpha-20240726144438-d85e825aca3e8ac57c7758d5ec88ed5c27358fcc",
"description": "Fetch API implementation for Node",

@@ -5,0 +5,0 @@ "sideEffects": false,

@@ -0,1 +1,2 @@

export { patchReadableFromWeb } from './utils.js';
export { fetchPonyfill as fetch } from './fetch.js';

@@ -2,0 +3,0 @@ export { PonyfillHeaders as Headers } from './Headers.js';

@@ -19,2 +19,3 @@ import { Readable } from 'stream';

static [Symbol.hasInstance](instance: unknown): instance is PonyfillReadableStream<unknown>;
[Symbol.toStringTag]: string;
}

@@ -22,2 +22,3 @@ import { BodyPonyfillInit, PonyfillBody, PonyfillBodyOptions } from './Body.js';

static json<T = any>(data: T, init?: ResponsePonyfilInit): PonyfillResponse<T>;
[Symbol.toStringTag]: string;
}
import { Readable } from 'stream';
export declare function patchReadableFromWeb(): void;
export declare function getHeadersObj(headers: Headers): Record<string, string>;

@@ -3,0 +4,0 @@ export declare function defaultHeadersSerializer(headers: Headers, onContentLength?: (value: string) => void): string[];

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc