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

@algolia/requester-browser-xhr

Package Overview
Dependencies
Maintainers
58
Versions
241
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@algolia/requester-browser-xhr - npm Package Compare versions

Comparing version 4.0.0-beta.4 to 4.0.0-beta.5

30

dist/requester-browser-xhr.cjs.js

@@ -12,11 +12,28 @@ 'use strict';

Object.keys(request.headers).forEach(key => baseRequester.setRequestHeader(key, request.headers[key]));
const timeoutHandler = setTimeout(() => {
baseRequester.abort();
resolve({ status: 0, content: '', isTimedOut: true });
}, request.timeout * 1000);
const createTimeout = (timeout, content) => {
return setTimeout(() => {
baseRequester.abort();
resolve({
status: 0,
content,
isTimedOut: true,
});
}, timeout * 1000);
};
const connectTimeout = createTimeout(request.connectTimeout, 'Connection timeout');
// eslint-disable-next-line functional/no-let
let socketTimeout;
// eslint-disable-next-line functional/immutable-data
baseRequester.onreadystatechange = () => {
if (baseRequester.readyState > baseRequester.OPENED && socketTimeout === undefined) {
clearTimeout(connectTimeout);
socketTimeout = createTimeout(request.socketTimeout, 'Socket timeout');
}
};
// eslint-disable-next-line functional/immutable-data
baseRequester.onerror = () => {
// istanbul ignore next
if (baseRequester.status === 0) {
clearTimeout(timeoutHandler);
clearTimeout(connectTimeout);
clearTimeout(socketTimeout);
resolve({

@@ -31,3 +48,4 @@ content: baseRequester.responseText || 'Network request failed',

baseRequester.onload = () => {
clearTimeout(timeoutHandler);
clearTimeout(connectTimeout);
clearTimeout(socketTimeout);
resolve({

@@ -34,0 +52,0 @@ content: baseRequester.responseText,

@@ -8,11 +8,28 @@ function createBrowserXhrRequester() {

Object.keys(request.headers).forEach(key => baseRequester.setRequestHeader(key, request.headers[key]));
const timeoutHandler = setTimeout(() => {
baseRequester.abort();
resolve({ status: 0, content: '', isTimedOut: true });
}, request.timeout * 1000);
const createTimeout = (timeout, content) => {
return setTimeout(() => {
baseRequester.abort();
resolve({
status: 0,
content,
isTimedOut: true,
});
}, timeout * 1000);
};
const connectTimeout = createTimeout(request.connectTimeout, 'Connection timeout');
// eslint-disable-next-line functional/no-let
let socketTimeout;
// eslint-disable-next-line functional/immutable-data
baseRequester.onreadystatechange = () => {
if (baseRequester.readyState > baseRequester.OPENED && socketTimeout === undefined) {
clearTimeout(connectTimeout);
socketTimeout = createTimeout(request.socketTimeout, 'Socket timeout');
}
};
// eslint-disable-next-line functional/immutable-data
baseRequester.onerror = () => {
// istanbul ignore next
if (baseRequester.status === 0) {
clearTimeout(timeoutHandler);
clearTimeout(connectTimeout);
clearTimeout(socketTimeout);
resolve({

@@ -27,3 +44,4 @@ content: baseRequester.responseText || 'Network request failed',

baseRequester.onload = () => {
clearTimeout(timeoutHandler);
clearTimeout(connectTimeout);
clearTimeout(socketTimeout);
resolve({

@@ -30,0 +48,0 @@ content: baseRequester.responseText,

{
"name": "@algolia/requester-browser-xhr",
"version": "4.0.0-beta.4",
"version": "4.0.0-beta.5",
"private": false,

@@ -11,2 +11,3 @@ "description": "Promise-based request library for browser using xhr.",

],
"sideEffects": false,
"main": "index.js",

@@ -16,4 +17,4 @@ "module": "dist/requester-browser-xhr.esm.js",

"dependencies": {
"@algolia/requester-common": "4.0.0-beta.4"
"@algolia/requester-common": "4.0.0-beta.5"
}
}
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