Comparing version 0.2.0 to 0.2.1
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
"use strict" | ||
@@ -86,3 +86,3 @@ var BitBuffer = require('bitbuffer').BitBuffer | ||
this.scaling = options.scaling || 2 | ||
this.initial_capacity = options.initial_capacity|| 1000 | ||
this.initial_capacity = options.initial_capacity || 1000 | ||
this.filters = [new SafeBloem(this.initial_capacity, error_rate * (1 - this.ratio))] | ||
@@ -111,3 +111,2 @@ } | ||
exports.Bloem = Bloem | ||
@@ -114,0 +113,0 @@ exports.SafeBloem = SafeBloem |
{ | ||
"name": "bloem", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"author": "Sebastian Wiedenroth <wiedi@frubar.net>", | ||
@@ -8,2 +8,10 @@ "description": "Bloom Filter using the FNV hash function", | ||
"main": "bloem.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/wiedi/node-bloem.git" | ||
}, | ||
"keywords": [ | ||
"bloom filter", | ||
"scalable bloom filters" | ||
], | ||
"dependencies": { | ||
@@ -10,0 +18,0 @@ "fnv": "0.1.x", |
@@ -25,3 +25,3 @@ # Bloem - Bloom Filter for node.js | ||
##### SafeBloem | ||
#### SafeBloem | ||
@@ -37,2 +37,75 @@ var bloem = require('bloem') | ||
## API | ||
### Class: Bloem | ||
##### new Bloem(size, slices) | ||
- <code>size</code> Number - bits in the bitfield | ||
- <code>slices</code> Number - how many hashfunctions to use | ||
Create a new Bloem filter object. | ||
##### filter.add(key) | ||
- <code>key</code> Buffer - key to add | ||
Add a key to the set | ||
##### filter.has(key) | ||
- <code>key</code> Buffer | ||
Test if key is in the set | ||
### Class: SafeBloem | ||
##### new SafeBloem(capacity, error_rate) | ||
- <code>capacity</code> Number - capacity of the filter | ||
- <code>error_rate</code> Number | ||
Create a new bloom filter that can hold <code>capacity</code> elements with an error probability of <code>error_rate</code>. | ||
##### filter.add(key) | ||
- <code>key</code> Buffer - key to add | ||
Add a key to the set. Returnes true on success and false if the filter is full. | ||
##### filter.has(key) | ||
- <code>key</code> Buffer | ||
Test if key is in the set | ||
### Class: ScalingBloem | ||
##### new ScalingBloem(error_rate, options) | ||
- <code>error_rate</code> Number | ||
Creates an instance of a scaling bloom filter. Accepts a "options" Object that takes the following values: | ||
- <code>initial_capacity</code> - the capacity of the first filter. Default: 1000 | ||
- <code>scaling</code> - the scaling factor. Use 2 here for less space usage but higher cpu usage or 4 for higher space, but lower cpu usage. Default: 2 | ||
- <code>ratio</code> - tightening ratio with 0 < ratio < 1. Default: 0.9 | ||
##### filter.add(key) | ||
- <code>key</code> Buffer - key to add | ||
Add a key to the set | ||
##### filter.has(key) | ||
- <code>key</code> Buffer | ||
Test if key is in the set | ||
## References | ||
@@ -39,0 +112,0 @@ |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
"use strict" | ||
var assert = require("assert") | ||
@@ -3,0 +3,0 @@ var bloem = require('./bloem') |
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
7614
113
0