Skip to content

Commit

Permalink
[fix] package.json and improved code
Browse files Browse the repository at this point in the history
  • Loading branch information
yawnt committed Oct 17, 2012
1 parent aed75be commit 2bfbda1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
26 changes: 16 additions & 10 deletions node.js/lib/client/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,16 +177,22 @@ Client.prototype.upload = function (uri, contentType, file, callback, success) {

success(response, result);
});

(function monkeyPatch(fn) {
out.write = function(data) {
emitter.emit('data', data);
fn.apply(out, arguments);
};
})(out.write);

out.on('end', function() {
emitter.emit('end');

out.on('request', function(request) {
var buffer = 0;
request.on('socket', function(s) {
var socket = s.socket;

var id = setInterval(function() {
var data = socket._bytesDispatched;
emitter.emit('data', data - buffer);
buffer = data;
if(buffer >= stat.size) {
clearInterval(id);
emitter.emit('end');
}
},100);
});
});

fs.createReadStream(file).pipe(out);
Expand Down
2 changes: 1 addition & 1 deletion node.js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"test": "vows --spec ./test/commands/*-test.js"
},
"dependencies": {
"request": "2.2.x"
"request": "2.11.x"
},
"devDependencies": {
"vows": "0.6.x",
Expand Down

0 comments on commit 2bfbda1

Please sign in to comment.