Improve code.

This commit is contained in:
Miao Jiang 2013-02-21 19:05:32 +08:00
parent 648e170fa8
commit 78a53743de
6 changed files with 41 additions and 41 deletions

View file

@ -1,6 +1,6 @@
// Generated by ToffeeScript 1.4.0
(function() {
var Curl, curls, id, m, p;
var Curl, id, m, p;
try {
Curl = require(__dirname + '/../build/Release/node-curl').Curl;
@ -8,10 +8,6 @@
Curl = require(__dirname + '/../build/default/node-curl').Curl;
}
curls = {};
id = 0;
Curl.prototype.setopt_user_ = function(option_id, value) {
return this.options[option_id] = value;
};
@ -58,26 +54,15 @@
};
Curl.prototype.on = function(event, callback) {
var _this = this;
switch (event) {
case 'data':
this.on_write = callback;
break;
case 'error':
this.on_error = function() {
var rt;
rt = callback();
curls[_this.id] = null;
return rt;
};
this.on_error = callback;
break;
case 'end':
this.on_end = function() {
var rt;
rt = callback();
curls[_this.id] = null;
return rt;
};
this.on_end = callback;
break;
default:
throw new Error("invalid event type " + event);
@ -85,9 +70,14 @@
return this;
};
Curl.prototype.close = function() {
return this.close_();
};
id = 0;
Curl.prototype.perform = function() {
this.id = ++id;
curls[this.id] = this;
this.perform_();
Curl.process();
return this;