0.2.2 • Published 1 year ago

@aggregion/binary-filter v0.2.2

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

JS Binary Filter

Small package for compact store numbers in bit mask, calculate count of unique numbers

Install

npm i @aggregion/binary-filter

Usage

Binary filter add entries:

import {BinaryFilter} from '@aggregion/binary-filter'


const filter = new BinaryFilter(10000);

filter.add(1);
filter.add(12);
filter.add(20);
filter.add(1);

filter.has(1) // true
filter.has(5) // false
filter.length // 3

Create from list

const filter = BinaryFilter.from([1,2,3]);

Union and intersections

const filter1 = BinaryFilter.from([1,2,3]);
const filter2 = BinaryFilter.from([2,3,5]);

const union = filter1.union(filter2); // new filter, that contains 1,2,3,5
const intersection = filter2.intersect(filter2); // new filter, that contains 2,3
0.2.2

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago