Skip to content
This repository was archived by the owner on Aug 19, 2025. It is now read-only.

jmalena/bloom-filter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Simple and dependency-free Bloom filter implementation

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors