Skip to main content

Built and signed on GitHub Actions

This is a standard bloom filter written in typescript.

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
100%
Published
2 months ago (201.7.1)

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

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 jsr:@imcotton/bloom

Import symbol

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

---- OR ----

Import directly with a jsr specifier

import * as bloom from "jsr:@imcotton/bloom";

Add Package

npx jsr add @imcotton/bloom

Import symbol

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

Add Package

yarn dlx jsr add @imcotton/bloom

Import symbol

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

Add Package

pnpm dlx jsr add @imcotton/bloom

Import symbol

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

Add Package

bunx jsr add @imcotton/bloom

Import symbol

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