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

@ -3,8 +3,6 @@ try
catch e
{Curl} = require __dirname + '/../build/default/node-curl'
curls = {}
id = 0
Curl::setopt_user_ = (option_id, value) ->
@options[option_id] = value
@ -52,24 +50,20 @@ Curl::on = (event, callback) ->
@on_write = callback
when 'error'
# (Error error) ->
@on_error = =>
rt = callback()
curls[@id] = null
rt
@on_error = callback
when 'end'
# () ->
@on_end = =>
rt = callback()
curls[@id] = null
rt
@on_end = callback
else
throw new Error("invalid event type #{event}")
@
Curl::close = () ->
@close_()
id = 0
Curl::perform = ->
@id = ++id
curls[@id] = @
@perform_()
Curl.process()
@
@ -96,5 +90,6 @@ Curl.process = ->
Curl.in_process = false
module.exports = Curl
# vim: sw=2 ts=2 sts=2 expandtab :