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.11-alpha-20240327142842-26e172534a26bc875f63385a16971fbdc5b95d8b to 0.5.11-rc-20240426123347-cab1f2d198b4b41c6a8951d576f361aac1c34e6d

1

cjs/fetchNodeHttp.js

@@ -90,2 +90,3 @@ "use strict";

}
nodeResponse.once('error', reject);
const ponyfillResponse = new Response_js_1.PonyfillResponse(responseBody, {

@@ -92,0 +93,0 @@ status: nodeResponse.statusCode,

3

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

@@ -31,3 +30,1 @@ Object.defineProperty(exports, "fetch", { enumerable: true, get: function () { return fetch_js_1.fetchPonyfill; } });

Object.defineProperty(exports, "URLSearchParams", { enumerable: true, get: function () { return URLSearchParams_js_1.PonyfillURLSearchParams; } });
// Not sure it is the right thing to do, but it is the only way to make it work for Fastify
(0, utils_js_1.patchReadableFromWeb)();
"use strict";
var _a;
Object.defineProperty(exports, "__esModule", { value: true });

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

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

@@ -178,2 +176,1 @@ this.readable = underlyingSource.readable;

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

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

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

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

exports.PonyfillResponse = PonyfillResponse;
_a = Symbol.toStringTag;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isNodeReadable = exports.isArrayBufferView = exports.fakePromise = exports.defaultHeadersSerializer = exports.getHeadersObj = exports.patchReadableFromWeb = void 0;
const stream_1 = require("stream");
exports.isNodeReadable = exports.isArrayBufferView = exports.fakePromise = exports.defaultHeadersSerializer = exports.getHeadersObj = void 0;
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);
};
}
}
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);
}
}
exports.patchReadableFromWeb = patchReadableFromWeb;
function getHeadersObj(headers) {

@@ -26,0 +8,0 @@ if (headers == null || !isHeadersInstance(headers)) {

@@ -87,2 +87,3 @@ import { request as httpRequest } from 'http';

}
nodeResponse.once('error', reject);
const ponyfillResponse = new PonyfillResponse(responseBody, {

@@ -89,0 +90,0 @@ status: nodeResponse.statusCode,

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

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

@@ -14,3 +13,1 @@ export { PonyfillHeaders as Headers } from './Headers.js';

export { PonyfillURLSearchParams as URLSearchParams } from './URLSearchParams.js';
// Not sure it is the right thing to do, but it is the only way to make it work for Fastify
patchReadableFromWeb();

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

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

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

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

@@ -174,2 +172,1 @@ this.readable = underlyingSource.readable;

}
_a = Symbol.toStringTag;

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

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

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

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

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

}
_a = Symbol.toStringTag;

@@ -1,21 +0,4 @@

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);
};
}
}
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) {

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

{
"name": "@whatwg-node/node-fetch",
"version": "0.5.11-alpha-20240327142842-26e172534a26bc875f63385a16971fbdc5b95d8b",
"version": "0.5.11-rc-20240426123347-cab1f2d198b4b41c6a8951d576f361aac1c34e6d",
"description": "Fetch API implementation for Node",

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

@@ -20,3 +20,2 @@ /// <reference types="node" />

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

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

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

@@ -5,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

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