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
554
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.0.1-alpha-20221005131815-b0ce77a to 0.0.1-alpha-20221225155445-dfcb269

TextEncoderDecoder.d.ts

4

Blob.d.ts

@@ -7,1 +7,5 @@ /// <reference types="node" />

}
export interface PonyfillBlob {
prototype: Blob;
new (blobParts?: BlobPart[], options?: BlobPropertyBag): Blob;
}

4

Body.d.ts

@@ -6,4 +6,4 @@ /// <reference types="node" />

import { PonyfillReadableStream } from './ReadableStream';
export declare type BodyPonyfillInit = XMLHttpRequestBodyInit | Readable | PonyfillReadableStream<Uint8Array>;
export declare class BodyPonyfill implements Body {
export type BodyPonyfillInit = XMLHttpRequestBodyInit | Readable | PonyfillReadableStream<Uint8Array>;
export declare class PonyfillBody implements Body {
private bodyInit;

@@ -10,0 +10,0 @@ bodyUsed: boolean;

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

export declare type PonyfillHeadersInit = [string, string][] | Record<string, string | string[] | undefined> | Headers;
export type PonyfillHeadersInit = [string, string][] | Record<string, string | string[] | undefined> | Headers;
export declare class PonyfillHeaders implements Headers {

@@ -3,0 +3,0 @@ private map;

export { fetchPonyfill as fetch } from './fetch';
export { PonyfillHeaders as Headers } from './Headers';
export { PonyfillBody as Body } from './Body';
export { PonyfillRequest as Request, RequestPonyfillInit as RequestInit } from './Request';

@@ -12,1 +13,2 @@ export { PonyfillResponse as Response, ResponsePonyfilInit as ResponseInit } from './Response';

export { PonyfillBlob as Blob } from './Blob';
export { PonyfillTextEncoder as TextEncoder, PonyfillTextDecoder as TextDecoder, PonyfillBtoa as btoa, } from './TextEncoderDecoder';

@@ -10,2 +10,4 @@ 'use strict';

const stream = require('stream');
const url = require('url');
const fs = require('fs');

@@ -129,3 +131,3 @@ // Will be removed after v14 reaches EOL

}
getReader() {
getReader(_options) {
const iterator = this.readable[Symbol.asyncIterator]();

@@ -232,4 +234,4 @@ return {

if (blob instanceof PonyfillFile) {
if (fileName == null) {
return new PonyfillFile([blob], name, { type: blob.type, lastModified: blob.lastModified });
if (fileName != null) {
return new PonyfillFile([blob], fileName, { type: blob.type, lastModified: blob.lastModified });
}

@@ -258,3 +260,3 @@ return blob;

})(BodyInitType || (BodyInitType = {}));
class BodyPonyfill {
class PonyfillBody {
constructor(bodyInit) {

@@ -470,3 +472,3 @@ this.bodyInit = bodyInit;

}
class PonyfillRequest extends BodyPonyfill {
class PonyfillRequest extends PonyfillBody {
constructor(input, options) {

@@ -537,3 +539,3 @@ let url;

class PonyfillResponse extends BodyPonyfill {
class PonyfillResponse extends PonyfillBody {
constructor(body, init) {

@@ -579,2 +581,11 @@ super(body || null);

}
static json(data, init = {}) {
return new PonyfillResponse(JSON.stringify(data), {
...init,
headers: {
"Content-Type": "application/json",
...init === null || init === void 0 ? void 0 : init.headers,
},
});
}
}

@@ -600,2 +611,6 @@

try {
if (fetchRequest.url.startsWith('file://')) {
resolve(new PonyfillResponse(fs.createReadStream(url.fileURLToPath(fetchRequest.url))));
return;
}
const requestFn = fetchRequest.url.startsWith('https') ? https.request : http.request;

@@ -651,2 +666,36 @@ const nodeReadable = fetchRequest.readable();

class PonyfillTextEncoder {
constructor(encoding = 'utf-8') {
this.encoding = encoding;
}
encode(input) {
return Buffer.from(input, this.encoding);
}
encodeInto(source, destination) {
const buffer = this.encode(source);
const copied = buffer.copy(destination);
return {
read: copied,
written: copied,
};
}
}
class PonyfillTextDecoder {
constructor(encoding = 'utf-8', options) {
this.encoding = encoding;
this.fatal = false;
this.ignoreBOM = false;
if (options) {
this.fatal = options.fatal || false;
this.ignoreBOM = options.ignoreBOM || false;
}
}
decode(input) {
return Buffer.from(input).toString(this.encoding);
}
}
function PonyfillBtoa(input) {
return Buffer.from(input, 'binary').toString('base64');
}
exports.AbortController = PonyfillAbortController;

@@ -656,2 +705,3 @@ exports.AbortError = PonyfillAbortError;

exports.Blob = PonyfillBlob;
exports.Body = PonyfillBody;
exports.File = PonyfillFile;

@@ -663,2 +713,5 @@ exports.FormData = PonyfillFormData;

exports.Response = PonyfillResponse;
exports.TextDecoder = PonyfillTextDecoder;
exports.TextEncoder = PonyfillTextEncoder;
exports.btoa = PonyfillBtoa;
exports.fetch = fetchPonyfill;
{
"name": "@whatwg-node/node-fetch",
"version": "0.0.1-alpha-20221005131815-b0ce77a",
"version": "0.0.1-alpha-20221225155445-dfcb269",
"description": "Fetch API implementation for Node",

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

@@ -8,2 +8,5 @@ /// <reference types="node" />

locked: boolean;
getReader(options: {
mode: "byob";
}): ReadableStreamBYOBReader;
getReader(): ReadableStreamDefaultReader<T>;

@@ -10,0 +13,0 @@ [Symbol.asyncIterator](): AsyncIterableIterator<any>;

@@ -1,8 +0,8 @@

import { BodyPonyfill, BodyPonyfillInit } from './Body';
import { PonyfillBody, BodyPonyfillInit } from './Body';
import { PonyfillHeadersInit } from './Headers';
export declare type RequestPonyfillInit = Omit<RequestInit, 'body' | 'headers'> & {
export type RequestPonyfillInit = Omit<RequestInit, 'body' | 'headers'> & {
body?: BodyPonyfillInit | null;
headers?: PonyfillHeadersInit;
};
export declare class PonyfillRequest extends BodyPonyfill implements Request {
export declare class PonyfillRequest extends PonyfillBody implements Request {
constructor(input: RequestInfo | URL, options?: RequestPonyfillInit);

@@ -9,0 +9,0 @@ get body(): import("./ReadableStream").PonyfillReadableStream<Uint8Array> | null;

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

import { BodyPonyfill, BodyPonyfillInit } from './Body';
import { PonyfillBody, BodyPonyfillInit } from './Body';
import { PonyfillHeadersInit } from './Headers';
export declare type ResponsePonyfilInit = Omit<ResponseInit, 'headers'> & {
export type ResponsePonyfilInit = Omit<ResponseInit, 'headers'> & {
url?: string;

@@ -8,3 +8,3 @@ redirected?: boolean;

};
export declare class PonyfillResponse extends BodyPonyfill implements Response {
export declare class PonyfillResponse extends PonyfillBody implements Response {
constructor(body?: BodyPonyfillInit | null, init?: ResponsePonyfilInit);

@@ -21,2 +21,3 @@ headers: Headers;

static redirect(url: string, status?: number): PonyfillResponse;
static json(data: any, init?: RequestInit): PonyfillResponse;
}

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