From 5964e27e056033f173537103ff5c218c5553379c Mon Sep 17 00:00:00 2001 From: Glenn Date: Sun, 8 Jul 2012 22:17:52 -0700 Subject: [PATCH] Adding support for number types --- bloomfilter.js | 4 ++-- test/bloomfilter-test.js | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/bloomfilter.js b/bloomfilter.js index eb81cbd..109c0fe 100644 --- a/bloomfilter.js +++ b/bloomfilter.js @@ -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, diff --git a/test/bloomfilter-test.js b/test/bloomfilter-test.js index 73971fe..03c0e45 100644 --- a/test/bloomfilter-test.js +++ b/test/bloomfilter-test.js @@ -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); + } } });