1.0.2 • Published 8 years ago

@jmalena/bloom-filter v1.0.2

Weekly downloads
-
License
-
Repository
github
Last release
8 years ago

Bloom filter

Simple and dependency-free Bloom filter implementation.

Bloom filter is a space-efficient data structure, which can test whether an element is not or is probably a member of a set.

Build Status

Installation

To install latest stable version:

npm install @jmalena/bloom-filter --save

Example

import BloomFilter from '@jmalena/bloom-filter'

const filter = new BloomFilter(65536, 2)

filter.add('redrum')

filter.containsMaybe('redrum') // true: "redrum" is probably in a set
filter.containsMaybe('otrozone') // false: "otrozone" is definitely not in a set

API

BloomFilter(length, hashCount[, hashFn1[, hashFn2]])

Custom hash function must take string as input and return unsigned 32-bit integer as output. It's highly recommended to hashFn1 and hashFn2 be different hash functions.

BloomFilter.add(str)

BloomFilter.containsMaybe(str)

Configuration

Length and number of hash functions can be calculated using this site.

Limitations

Currently works only with length up to 2^32, due to JavaScript integer limitations.

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago