Comparing version 0.1.0 to 0.1.1
@@ -5,2 +5,4 @@ 'use strict'; | ||
, listeners = require('loads') | ||
, send = require('xhr-send') | ||
, hang = require('hang') | ||
, AXO = require('axo'); | ||
@@ -76,4 +78,4 @@ | ||
this.on('stream', function stream(data) { | ||
if (socket.multipart) return this.emit('data', data); | ||
requests.on('stream', function stream(data) { | ||
if (socket.multipart) return requests.emit('data', data); | ||
@@ -85,10 +87,10 @@ // | ||
// | ||
var chunk = data.slice(this.offset); | ||
this.offset = data.length; | ||
var chunk = data.slice(requests.offset); | ||
requests.offset = data.length; | ||
this.emit('data', chunk); | ||
requests.emit('data', chunk); | ||
}); | ||
this.on('end', function cleanup() { | ||
delete Requests.active[this.id]; | ||
requests.on('end', function cleanup() { | ||
delete Requests.active[requests.id]; | ||
}); | ||
@@ -108,5 +110,5 @@ | ||
// | ||
this.header('Content-Type', 'text/plain'); | ||
requests.header('Content-Type', 'text/plain'); | ||
for (what in options.headers) { | ||
this.header(what, options.headers[what]); | ||
requests.header(what, options.headers[what]); | ||
} | ||
@@ -117,3 +119,3 @@ | ||
// | ||
if (this.streaming) { | ||
if (requests.streaming) { | ||
if ('string' === typeof options.body) { | ||
@@ -134,6 +136,13 @@ if ('multipart' in socket) { | ||
listeners(socket, this, this.streaming); | ||
this.emit('before', socket); | ||
listeners(socket, requests, requests.streaming); | ||
requests.emit('before', socket); | ||
socket.send(options.body); | ||
send(socket, options.body, hang(function send(err) { | ||
if (err) { | ||
requests.emit('error', err); | ||
requests.emit('end', err); | ||
} | ||
requests.emit('send'); | ||
})); | ||
}; | ||
@@ -140,0 +149,0 @@ |
{ | ||
"name": "requests", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "An XHR abstraction that works in browsers and node.js", | ||
@@ -38,3 +38,5 @@ "main": "index.js", | ||
"eventemitter3": "0.1.x", | ||
"loads": "0.0.x" | ||
"hang": "1.0.x", | ||
"loads": "0.0.x", | ||
"xhr-send": "1.0.x" | ||
}, | ||
@@ -41,0 +43,0 @@ "devDependencies": { |
@@ -82,2 +82,3 @@ # requests | ||
- `before` Emitted before we send the actual request. | ||
- `send` Emitted after we've succesfully started the sending of the data. | ||
@@ -84,0 +85,0 @@ ### requests#destroy |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
18063
356
107
3
5
+ Addedhang@1.0.x
+ Addedxhr-send@1.0.x
+ Addedhang@1.0.0(transitive)
+ Addedxhr-send@1.0.0(transitive)