Skip to content

Commit

Permalink
change local var of TwitterNode instance from node => twit, node look…
Browse files Browse the repository at this point in the history
…ed too much like a node object or something
  • Loading branch information
technoweenie committed Mar 15, 2010
1 parent f304d10 commit 0f485ce
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions lib/index.js
Expand Up @@ -52,7 +52,7 @@ TwitterNode.prototype.stream = function() {
// FIXME: process.mixin depreciating
var client = this.createClient(this.port, this.host),
headers = process.mixin({}, this.headers),
node = this,
twit = this,
request;

headers['Host'] = this.host
Expand All @@ -62,33 +62,33 @@ TwitterNode.prototype.stream = function() {
request = client.request("GET", this.requestUrl(), headers);

request.addListener('response', function(response) {
if (node._clientResponse && node._clientResponse.connection) {
node._clientResponse.connection.close();
if (twit._clientResponse && twit._clientResponse.connection) {
twit._clientResponse.connection.close();
}
node._clientResponse = response;
twit._clientResponse = response;

response.setBodyEncoding('utf8');
response.addListener('data', function(chunk) {
node.parser.receive(chunk);
twit.parser.receive(chunk);
});
response.addListener('end', function() {
node.emit('close', this)
twit.emit('close', this)
});
});
request.close();
return this;
};

TwitterNode.prototype.setupJSONParser = function() {
var node = this;
var twit = this;
this.parser = new parser.instance();
this.parser.addListener('object', function(tweet) {
if(tweet.limit) {
node.emit('limit', tweet.limit)
twit.emit('limit', tweet.limit)
} else if(tweet['delete']) {
node.emit('delete', tweet['delete'])
twit.emit('delete', tweet['delete'])
} else {
node.emit('tweet', tweet)
twit.emit('tweet', tweet)
}
})
};
Expand Down

0 comments on commit 0f485ce

Please sign in to comment.