Adding support for number types

This commit is contained in:
Glenn 2012-07-08 22:17:52 -07:00
parent dac2d326a0
commit 5964e27e05
2 changed files with 9 additions and 3 deletions

View File

@ -42,7 +42,7 @@
};
BloomFilter.prototype.add = function(v) {
var l = this.locations(v),
var l = this.locations(v.toString()),
i = -1,
k = this.k,
buckets = this.buckets;
@ -50,7 +50,7 @@
};
BloomFilter.prototype.test = function(v) {
var l = this.locations(v),
var l = this.locations(v.toString()),
i = -1,
k = this.k,
b,

View File

@ -42,7 +42,13 @@ suite.addBatch({
var f = new BloomFilter(20, 10);
f.add("abc");
assert.equal(f.test("wtf"), false);
}
},
"works with integer types": function() {
var f = new BloomFilter(1000, 4);
f.add(1);
assert.equal(f.test(1), true);
assert.equal(f.test(2), false);
}
}
});