Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use .slice() to generate array of messages to send to callbacks.

  • Loading branch information...
commit 5dc4946f33f946234f4b91d3437248d1760d7629 1 parent 50c1bcb
@scottgonzalez authored
Showing with 7 additions and 6 deletions.
  1. +7 −6 lib/channel.js
View
13 lib/channel.js
@@ -46,14 +46,15 @@ extend(Channel.prototype, {
},
query: function(since, callback) {
- // TODO: just use .slice()
- var matching = [];
- for (var i = 0; i < this.messages.length; i++) {
- var message = this.messages[i];
- if (message.timestamp > since) {
- matching.push(message);
+ var matching = [],
+ length = this.messages.length;
+ for (var i = 0; i < length; i++) {
+ if (this.messages[i].timestamp > since) {
+ matching = this.messages.slice(i);
+ break;
}
}
+
if (matching.length) {
callback(matching);
} else {

0 comments on commit 5dc4946

Please sign in to comment.
Something went wrong with that request. Please try again.