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

xhr

Package Overview
Dependencies
Maintainers
2
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xhr - npm Package Compare versions

Comparing version 2.2.1 to 2.2.2

18

index.js

@@ -54,7 +54,14 @@ "use strict";

function _createXHR(options) {
var callback = options.callback
if(typeof callback === "undefined"){
if(typeof options.callback === "undefined"){
throw new Error("callback argument missing")
}
var called = false
var callback = function cbOnce(err, response, body){
if(!called){
called = true
options.callback(err, response, body)
}
}
function readystatechange() {

@@ -100,4 +107,3 @@ if (xhr.readyState === 4) {

evt.statusCode = 0
callback(evt, failureResponse)
callback = noop
return callback(evt, failureResponse)
}

@@ -134,5 +140,3 @@

}
callback(err, response, response.body)
callback = noop
return callback(err, response, response.body)
}

@@ -139,0 +143,0 @@

{
"name": "xhr",
"version": "2.2.1",
"version": "2.2.2",
"description": "small xhr abstraction",

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

@@ -55,2 +55,18 @@ var window = require("global/window")

test("[func] Calls the callback once even if error is thrown issue #127", function(assert) {
var count = 0;
setTimeout(function(){
assert.equal(count, 1, "expected one call")
assert.end()
},100)
try{
xhr({
uri: "instanterror://foo"
}, function(err, resp, body) {
count++;
throw Error("dummy error")
})
} catch(e){}
})
test("[func] Times out to an error ", function(assert) {

@@ -57,0 +73,0 @@ xhr({

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