Skip to main content

Built and signed on GitHub Actions

This is a standard bloom filter written in typescript.

This package works with Bun, Cloudflare Workers, Node.js, Deno, Browsers
JSR Score
100%
Published
3 days ago (201.6.1)
Note

This is a forked version of (https://jsr.io/@kgwinnup/bloom),
featuring significant internal rewrites from class-based to functional implementation.

Stick to the original unless you're specifically interested in functional programming characteristics.

Bloom filter (classless)

JSR codecov

create

const filter1 = bloom_by(4000, 1e-7);

const filter2 = bloom_from(filter1.dump());

swap

create new filter with internal hashing algorithm replaced from the default Murmur3

import fnv1a      from '@imcotton/bloom/hashing/fnv1a';
import fnv1a_deno from '@imcotton/bloom/hashing/fnv1a-deno';

const bloom = bloom_by(4000, 1e-7);

const bloom_fnv1a = bloom.swap(fnv1a);

const bloom_fnv1a_deno = bloom.swap(fnv1a_deno);

insert

immutable insertion

let filter = bloom_by(4000, 1e-7);

filter = filter.insert(a);

filter = filter.batch_insert([ b, c ]);

filter = await filter.async_batch_insert(
    ReadableStream.from([ d, e, f ]),
);

lookup

const { lookup } = bloom_by(4000, 1e-7).insert(a);

lookup(a); // true
lookup(b); // false
Built and signed on
GitHub Actions
View transparency log

Add Package

deno add @imcotton/bloom

Import symbol

import * as mod from "@imcotton/bloom";

Add Package

npx jsr add @imcotton/bloom

Import symbol

import * as mod from "@imcotton/bloom";

Add Package

yarn dlx jsr add @imcotton/bloom

Import symbol

import * as mod from "@imcotton/bloom";

Add Package

pnpm dlx jsr add @imcotton/bloom

Import symbol

import * as mod from "@imcotton/bloom";

Add Package

bunx jsr add @imcotton/bloom

Import symbol

import * as mod from "@imcotton/bloom";