Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
  • 3 commits
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Showing with 27 additions and 7 deletions.
  1. +27 −7 faststats.js
View
34 faststats.js
@@ -168,13 +168,15 @@ Stats.prototype = {
if(this.buckets) {
var b=this._find_bucket(a);
- this.buckets[b][0] -= tuple.shift();
-
- if(this.buckets[b][0] === 0)
- delete this.buckets[b];
- else
- for(i=0; i<tuple.length; i++)
- this.buckets[b][i+1] = (this.buckets[b][i+1]|0) - (tuple[i]|0);
+ if(this.buckets[b]) {
+ this.buckets[b][0] -= tuple.shift();
+
+ if(this.buckets[b][0] === 0)
+ delete this.buckets[b];
+ else
+ for(i=0; i<tuple.length; i++)
+ this.buckets[b][i+1] = (this.buckets[b][i+1]|0) - (tuple[i]|0);
+ }
}
this._reset_cache();
@@ -218,6 +220,24 @@ Stats.prototype = {
this._del_cache(tuple);
},
+ reset_tuples: function(tuple) {
+ var b, l, t, ts=tuple.length;
+ if(!this.buckets) {
+ throw new Error("reset_tuple is only valid when using buckets");
+ }
+
+ for(b=0, l=this.buckets.length; b<l; i++) {
+ if(!this.buckets[b]) {
+ continue;
+ }
+ for(t=0; t<ts; t++) {
+ if(typeof tuple[t] !== 'undefined') {
+ this.buckets[b][t] = tuple[t];
+ }
+ }
+ }
+ }
+
unshift: function() {
var i, a, args=Array.prototype.slice.call(arguments, 0);
if(args.length && args[0] instanceof Array)

No commit comments for this range

Something went wrong with that request. Please try again.