Comparing version 0.0.7 to 0.1.0
100
lib/xhr2.js
@@ -1,4 +0,4 @@ | ||
// Generated by CoffeeScript 1.6.3 | ||
// Generated by CoffeeScript 1.7.1 | ||
(function() { | ||
var InvalidStateError, NetworkError, SecurityError, XMLHttpRequest, XMLHttpRequestEventTarget, XMLHttpRequestProgressEvent, XMLHttpRequestUpload, http, https, os, url, _ref, | ||
var InvalidStateError, NetworkError, ProgressEvent, SecurityError, XMLHttpRequest, XMLHttpRequestEventTarget, XMLHttpRequestUpload, http, https, os, url, | ||
__hasProp = {}.hasOwnProperty, | ||
@@ -55,2 +55,3 @@ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; | ||
var eventType, listener, listeners, _i, _len; | ||
event.currentTarget = event.target = this; | ||
eventType = event.type; | ||
@@ -60,7 +61,7 @@ if (listeners = this._listeners[eventType]) { | ||
listener = listeners[_i]; | ||
listener(event); | ||
listener.call(this, event); | ||
} | ||
} | ||
if (listener = this["on" + eventType]) { | ||
listener(event); | ||
listener.call(this, event); | ||
} | ||
@@ -340,3 +341,3 @@ return void 0; | ||
this.readyState = newReadyState; | ||
event = new XMLHttpRequestProgressEvent('readystatechange', this); | ||
event = new ProgressEvent('readystatechange'); | ||
this.dispatchEvent(event); | ||
@@ -370,4 +371,3 @@ return void 0; | ||
XMLHttpRequest.prototype._sendHxxpRequest = function() { | ||
var agent, hxxp, request, | ||
_this = this; | ||
var agent, hxxp, request; | ||
if (this._url.protocol === 'http:') { | ||
@@ -391,12 +391,18 @@ hxxp = http; | ||
if (this.timeout) { | ||
request.setTimeout(this.timeout, function() { | ||
return _this._onHttpTimeout(request); | ||
}); | ||
request.setTimeout(this.timeout, (function(_this) { | ||
return function() { | ||
return _this._onHttpTimeout(request); | ||
}; | ||
})(this)); | ||
} | ||
request.on('response', function(response) { | ||
return _this._onHttpResponse(request, response); | ||
}); | ||
request.on('error', function(error) { | ||
return _this._onHttpRequestError(request, error); | ||
}); | ||
request.on('response', (function(_this) { | ||
return function(response) { | ||
return _this._onHttpResponse(request, response); | ||
}; | ||
})(this)); | ||
request.on('error', (function(_this) { | ||
return function(error) { | ||
return _this._onHttpRequestError(request, error); | ||
}; | ||
})(this)); | ||
this.upload._startUpload(request); | ||
@@ -421,4 +427,3 @@ if (this._request === request) { | ||
XMLHttpRequest.prototype._onHttpResponse = function(request, response) { | ||
var lengthString, | ||
_this = this; | ||
var lengthString; | ||
if (this._request !== request) { | ||
@@ -449,11 +454,17 @@ return; | ||
this._response = response; | ||
this._response.on('data', function(data) { | ||
return _this._onHttpResponseData(response, data); | ||
}); | ||
this._response.on('end', function() { | ||
return _this._onHttpResponseEnd(response); | ||
}); | ||
this._response.on('close', function() { | ||
return _this._onHttpResponseClose(response); | ||
}); | ||
this._response.on('data', (function(_this) { | ||
return function(data) { | ||
return _this._onHttpResponseData(response, data); | ||
}; | ||
})(this)); | ||
this._response.on('end', (function(_this) { | ||
return function() { | ||
return _this._onHttpResponseEnd(response); | ||
}; | ||
})(this)); | ||
this._response.on('close', (function(_this) { | ||
return function() { | ||
return _this._onHttpResponseClose(response); | ||
}; | ||
})(this)); | ||
this.status = this._response.statusCode; | ||
@@ -532,3 +543,3 @@ this.statusText = http.STATUS_CODES[this.status]; | ||
var event; | ||
event = new XMLHttpRequestProgressEvent(eventType, this); | ||
event = new ProgressEvent(eventType); | ||
event.lengthComputable = this._lengthComputable; | ||
@@ -717,4 +728,3 @@ event.loaded = this._loadedBytes; | ||
function InvalidStateError() { | ||
_ref = InvalidStateError.__super__.constructor.apply(this, arguments); | ||
return _ref; | ||
return InvalidStateError.__super__.constructor.apply(this, arguments); | ||
} | ||
@@ -741,7 +751,7 @@ | ||
XMLHttpRequestProgressEvent = (function() { | ||
function XMLHttpRequestProgressEvent(type, target) { | ||
ProgressEvent = (function() { | ||
function ProgressEvent(type) { | ||
this.type = type; | ||
this.target = target; | ||
this.currentTarget = this.target; | ||
this.target = null; | ||
this.currentTarget = null; | ||
this.lengthComputable = false; | ||
@@ -752,19 +762,19 @@ this.loaded = 0; | ||
XMLHttpRequestProgressEvent.prototype.bubbles = false; | ||
ProgressEvent.prototype.bubbles = false; | ||
XMLHttpRequestProgressEvent.prototype.cancelable = false; | ||
ProgressEvent.prototype.cancelable = false; | ||
XMLHttpRequestProgressEvent.prototype.target = null; | ||
ProgressEvent.prototype.target = null; | ||
XMLHttpRequestProgressEvent.prototype.loaded = null; | ||
ProgressEvent.prototype.loaded = null; | ||
XMLHttpRequestProgressEvent.prototype.lengthComputable = null; | ||
ProgressEvent.prototype.lengthComputable = null; | ||
XMLHttpRequestProgressEvent.prototype.total = null; | ||
ProgressEvent.prototype.total = null; | ||
return XMLHttpRequestProgressEvent; | ||
return ProgressEvent; | ||
})(); | ||
XMLHttpRequest.XMLHttpRequestProgressEvent = XMLHttpRequestProgressEvent; | ||
XMLHttpRequest.ProgressEvent = ProgressEvent; | ||
@@ -787,3 +797,3 @@ XMLHttpRequestUpload = (function(_super) { | ||
XMLHttpRequestUpload.prototype._setData = function(data) { | ||
var body, i, offset, view, _i, _j, _ref1, _ref2; | ||
var body, i, offset, view, _i, _j, _ref, _ref1; | ||
if (typeof data === 'undefined' || data === null) { | ||
@@ -802,3 +812,3 @@ return; | ||
view = new Uint8Array(data); | ||
for (i = _i = 0, _ref1 = data.byteLength; 0 <= _ref1 ? _i < _ref1 : _i > _ref1; i = 0 <= _ref1 ? ++_i : --_i) { | ||
for (i = _i = 0, _ref = data.byteLength; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) { | ||
body[i] = view[i]; | ||
@@ -811,3 +821,3 @@ } | ||
view = new Uint8Array(data.buffer); | ||
for (i = _j = 0, _ref2 = data.byteLength; 0 <= _ref2 ? _j < _ref2 : _j > _ref2; i = 0 <= _ref2 ? ++_j : --_j) { | ||
for (i = _j = 0, _ref1 = data.byteLength; 0 <= _ref1 ? _j < _ref1 : _j > _ref1; i = 0 <= _ref1 ? ++_j : --_j) { | ||
body[i] = view[i + offset]; | ||
@@ -814,0 +824,0 @@ } |
{ | ||
"name": "xhr2", | ||
"version": "0.0.7", | ||
"version": "0.1.0", | ||
"description": "XMLHttpRequest emulation for node.js", | ||
@@ -26,12 +26,12 @@ "keywords": ["xhr", "xmlhttprequest", "ajax", "browser"], | ||
"async": ">= 0.2.8", | ||
"chai": ">= 1.6.0", | ||
"codo": ">= 1.6.1", | ||
"coffee-script": ">= 1.6.2", | ||
"express": ">= 3.2.4", | ||
"glob": ">= 3.2.1", | ||
"mocha": ">= 1.9.0", | ||
"open": ">= 0.0.3", | ||
"chai": ">= 1.9.1", | ||
"codo": ">= 2.0.9", | ||
"coffee-script": ">= 1.7.1", | ||
"express": ">= 4.8.3", | ||
"glob": ">= 4.0.5", | ||
"mocha": ">= 1.21.4", | ||
"open": ">= 0.0.5", | ||
"remove": ">= 0.1.5", | ||
"sinon": ">= 1.7.2", | ||
"sinon-chai": ">= 2.4.0" | ||
"sinon": ">= 1.10.3", | ||
"sinon-chai": ">= 2.5.0" | ||
}, | ||
@@ -38,0 +38,0 @@ "main": "lib/xhr2.js", |
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
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
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
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
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
112105
29
731
0