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

@algolia/requester-fetch

Package Overview
Dependencies
Maintainers
84
Versions
184
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@algolia/requester-fetch - npm Package Compare versions

Comparing version 5.10.0 to 5.10.1

67

dist/requester.fetch.browser.d.ts

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

// src/createFetchRequester.ts
function isAbortError(error) {
return error instanceof Error && error.name === "AbortError";
}
function getErrorMessage(error, abortContent) {
if (isAbortError(error)) {
return abortContent;
}
return error instanceof Error ? error.message : "Network request failed";
}
function createFetchRequester({ requesterOptions = {} } = {}) {
async function send(request) {
const abortController = new AbortController();
const signal = abortController.signal;
const createTimeout = (timeout) => {
return setTimeout(() => {
abortController.abort();
}, timeout);
};
const connectTimeout = createTimeout(request.connectTimeout);
let fetchRes;
try {
fetchRes = await fetch(request.url, {
method: request.method,
body: request.data || null,
redirect: "manual",
signal,
...requesterOptions,
headers: {
...requesterOptions.headers,
...request.headers
}
});
} catch (error) {
return {
status: 0,
content: getErrorMessage(error, "Connection timeout"),
isTimedOut: isAbortError(error)
};
}
clearTimeout(connectTimeout);
createTimeout(request.responseTimeout);
try {
const content = await fetchRes.text();
return {
content,
isTimedOut: false,
status: fetchRes.status
};
} catch (error) {
return {
status: 0,
content: getErrorMessage(error, "Socket timeout"),
isTimedOut: isAbortError(error)
};
}
}
return { send };
}
import { Requester } from '@algolia/client-common';
export { createFetchRequester };
type FetchRequesterOptions = {
readonly requesterOptions?: RequestInit;
};
declare function createFetchRequester({ requesterOptions }?: FetchRequesterOptions): Requester;
export { type FetchRequesterOptions, createFetchRequester };

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

// src/createFetchRequester.ts
function isAbortError(error) {
return error instanceof Error && error.name === "AbortError";
}
function getErrorMessage(error, abortContent) {
if (isAbortError(error)) {
return abortContent;
}
return error instanceof Error ? error.message : "Network request failed";
}
function createFetchRequester({ requesterOptions = {} } = {}) {
async function send(request) {
const abortController = new AbortController();
const signal = abortController.signal;
const createTimeout = (timeout) => {
return setTimeout(() => {
abortController.abort();
}, timeout);
};
const connectTimeout = createTimeout(request.connectTimeout);
let fetchRes;
try {
fetchRes = await fetch(request.url, {
method: request.method,
body: request.data || null,
redirect: "manual",
signal,
...requesterOptions,
headers: {
...requesterOptions.headers,
...request.headers
}
});
} catch (error) {
return {
status: 0,
content: getErrorMessage(error, "Connection timeout"),
isTimedOut: isAbortError(error)
};
}
clearTimeout(connectTimeout);
createTimeout(request.responseTimeout);
try {
const content = await fetchRes.text();
return {
content,
isTimedOut: false,
status: fetchRes.status
};
} catch (error) {
return {
status: 0,
content: getErrorMessage(error, "Socket timeout"),
isTimedOut: isAbortError(error)
};
}
}
return { send };
}
import { Requester } from '@algolia/client-common';
export { createFetchRequester };
type FetchRequesterOptions = {
readonly requesterOptions?: RequestInit;
};
declare function createFetchRequester({ requesterOptions }?: FetchRequesterOptions): Requester;
export { type FetchRequesterOptions, createFetchRequester };

4

package.json
{
"name": "@algolia/requester-fetch",
"version": "5.10.0",
"version": "5.10.1",
"description": "Promise-based request library using Fetch.",

@@ -50,3 +50,3 @@ "repository": {

"dependencies": {
"@algolia/client-common": "5.10.0"
"@algolia/client-common": "5.10.1"
},

@@ -53,0 +53,0 @@ "devDependencies": {

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