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

fetch-with-file-support

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fetch-with-file-support - npm Package Compare versions

Comparing version 1.2.0 to 2.0.0

8

dist/auto.node.js

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

import { fetch as fetchUnbound } from "./index.node.js";
const fetch = fetchUnbound.bind({
fetch: globalThis.fetch,
Request,
Response,
Headers,
});
import { fetch } from "./index.node.js";
globalThis.fetch = fetch;

@@ -1,6 +0,1 @@

export declare function fetch(this: undefined | any | {
fetch: typeof globalThis.fetch;
Request: typeof globalThis.Request;
Response: typeof globalThis.Response;
Headers: typeof globalThis.Headers;
}, input: RequestInfo, init?: RequestInit | undefined): Promise<any>;
export declare const fetch: typeof globalThis.fetch;

5

dist/index.default.js

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

export async function fetch(input, init = {}) {
const { fetch = globalThis.fetch, Request = globalThis.Request, Response = globalThis.Response, Headers = globalThis.Headers, } = this ?? globalThis;
return await fetch(input, init);
}
export const { fetch } = globalThis;

@@ -1,6 +0,1 @@

export declare function fetch(this: undefined | any | {
fetch: typeof globalThis.fetch;
Request: typeof globalThis.Request;
Response: typeof globalThis.Response;
Headers: typeof globalThis.Headers;
}, input: RequestInfo, init?: RequestInit | undefined): Promise<any>;
export declare const fetch: typeof globalThis.fetch;

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

export async function fetch(input, init = {}) {
const { fetch = globalThis.fetch, Request = globalThis.Request, Response = globalThis.Response, Headers = globalThis.Headers, } = this ?? globalThis;
return await fetch(input, init);
}
export const { fetch } = globalThis;

@@ -1,6 +0,1 @@

export declare function fetch(this: undefined | any | {
fetch: typeof globalThis.fetch;
Request: typeof globalThis.Request;
Response: typeof globalThis.Response;
Headers: typeof globalThis.Headers;
}, input: RequestInfo, init?: RequestInit | undefined): Promise<any>;
export declare function fetch(input: RequestInfo, init?: RequestInit | undefined): Promise<Response>;
import openAsBlob from "./lib/node-fs-openAsBlob.js";
const { fetch: globalThisFetch, Request, Response, Headers } = globalThis;
export async function fetch(input, init = {}) {
const { fetch = globalThis.fetch, Request = globalThis.Request, Response = globalThis.Response, Headers = globalThis.Headers, } = this ?? globalThis;
const request = input instanceof Request && !init ? input : new Request(input, init);

@@ -22,4 +22,4 @@ if (request.url.startsWith("file:")) {

else {
return await fetch(request);
return await globalThisFetch(request);
}
}
{
"name": "fetch-with-file-support",
"version": "1.2.0",
"version": "2.0.0",
"description": "📂 fetch() but with support for file:///my/file.txt URLs",

@@ -5,0 +5,0 @@ "keywords": [

@@ -86,16 +86,2 @@ # `fetch()` with `file:` support

If you want to bring your own `fetch()` implementation, you can bind the `this`
context of the `fetch()` function to an object with `options.fetch`,
`options.Request`, `options.Response`, and `options.Headers` properties. The
implementation will use these instead of the globals.
```js
import * as undici from "undici";
import { fetch as fetchUnbound } from "fetch-with-file-support";
const fetch = fetchUnbound.bind(undici);
const response = await fetch(new URL("./package.json", import.meta.url));
const json = await response.json();
```
🌎 If you prefer global polyfills, you can import

@@ -102,0 +88,0 @@ `fetch-with-file-support/auto`.

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