Skip to content

Commit

Permalink
v2.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
SalvatorePreviti committed Sep 18, 2024
1 parent f7fb706 commit fdaf825
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 89 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
- run: npm install --exact --no-audit --no-save
env:
ROARING_NODE_PRE_GYP: "false"
- run: npx tsc --noEmit
- run: npx eslint --no-error-on-unmatched-pattern --max-warnings=0
- run: npx prettier --loglevel=warn --check .
- run: node ./node-pre-gyp.js
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
node-version: "22.x"
registry-url: "https://registry.npmjs.org"
- run: npm install --exact --no-audit --no-save
- run: npx tsc --noEmit
- run: node ./scripts/test.js
- run: node --expose-gc ./scripts/test-memory-leaks.js
- run: npm publish --provenance --access public
Expand Down
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"eslint.validate": [],
"javascript.format.semicolons": "insert",
"typescript.format.semicolons": "insert",
"typescript.tsdk": "node_modules/typescript/lib",
"files.eol": "\n",
"search.exclude": {
"roaring-node.cpp": true,
Expand Down
38 changes: 27 additions & 11 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,21 @@ Roaring Bitmap 32 documentation at: https://salvatorepreviti.github.io/roaring-n

import roaring = require("./");

export interface ReadonlySetLike<T> {
/**
* Despite its name, returns an iterator of the values in the set-like.
*/
keys(): Iterator<T>;
/**
* @returns a boolean indicating whether an element with the specified value exists in the set-like or not.
*/
has(value: T): boolean;
/**
* @returns the number of (unique) elements in the set-like.
*/
readonly size: number;
}

/** Gets the approximate memory allocated by the roaring bitmap library. */
export function getRoaringUsedMemory(): number;

Expand Down Expand Up @@ -339,7 +354,8 @@ export enum FrozenViewFormat {

export type FrozenViewFormatType = FrozenViewFormat | "unsafe_frozen_croaring" | "unsafe_frozen_portable";

export interface ReadonlyRoaringBitmap32 extends ReadonlySet<number> {
export interface ReadonlyRoaringBitmap32
extends Omit<ReadonlySet<number>, "forEach" | "keys" | "values" | "entries" | typeof Symbol.iterator> {
/**
* Property. Gets the number of items in the set (cardinality).
*
Expand Down Expand Up @@ -442,7 +458,7 @@ export interface ReadonlyRoaringBitmap32 extends ReadonlySet<number> {
* @returns {RoaringBitmap32Iterator} A new iterator
* @memberof ReadonlyRoaringBitmap32
*/
entries(): IterableIterator<[number, number]>;
entries(): ReturnType<Set<number>["entries"]>;

/**
* Executes a function for each value in the set, in ascending order.
Expand Down Expand Up @@ -1262,14 +1278,14 @@ export interface ReadonlyRoaringBitmap32 extends ReadonlySet<number> {
isDisjointFrom(other: ReadonlySetLike<unknown> | ReadonlyRoaringBitmap32): boolean;
}

export interface RoaringBitmap32 extends ReadonlyRoaringBitmap32, Set<number> {
export interface RoaringBitmap32 extends ReadonlyRoaringBitmap32 {
/**
* Property: The version of the CRoaring libary as a string.
* Property: The version of the CRoaring library as a string.
* Example: "0.9.2"
*
* @export
* @constant
* @type {string} The version of the CRoaring libary as a string. Example: "0.9.2"
* @type {string} The version of the CRoaring library as a string. Example: "0.9.2"
* @memberof RoaringBitmap32
*/
get CRoaringVersion(): string;
Expand Down Expand Up @@ -1681,7 +1697,7 @@ export interface RoaringBitmap32 extends ReadonlyRoaringBitmap32, Set<number> {
/**
* @returns a new RoaringBitmap32 containing all the elements in this Set which are not also in the argument.
*/
difference<U>(other: ReadonlyRoaringBitmap32): RoaringBitmap32;
difference(other: ReadonlyRoaringBitmap32): RoaringBitmap32;

/**
* Warning: this method is just for compatibility with Set and returns a Set, so it can be very slow for big bitmaps.
Expand Down Expand Up @@ -1849,12 +1865,12 @@ export class RoaringBitmap32 {
): boolean;

/**
* Property: The version of the CRoaring libary as a string.
* Property: The version of the CRoaring library as a string.
* Example: "0.4.0"
*
* @export
* @constant
* @type {string} The version of the CRoaring libary as a string. Example: "0.2.42"
* @type {string} The version of the CRoaring library as a string. Example: "0.2.42"
*/
static get CRoaringVersion(): string;

Expand Down Expand Up @@ -2291,7 +2307,7 @@ export class RoaringBitmap32 {
/**
* @returns a new RoaringBitmap32 containing all the elements in this Set which are not also in the argument.
*/
difference<U>(other: ReadonlyRoaringBitmap32): RoaringBitmap32;
difference(other: ReadonlyRoaringBitmap32): RoaringBitmap32;

/**
* Warning: this method is just for compatibility with Set and returns a Set, so it can be very slow for big bitmaps.
Expand Down Expand Up @@ -2545,12 +2561,12 @@ export interface RoaringBitmap32Statistics {
}

/**
* Property: The version of the CRoaring libary as a string.
* Property: The version of the CRoaring library as a string.
* Example: "0.4.0"
*
* @export
* @constant
* @type {string} The version of the CRoaring libary as a string. Example: "0.2.42"
* @type {string} The version of the CRoaring library as a string. Example: "0.2.42"
* @memberof RoaringModule
*/
export const CRoaringVersion: string;
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
"update-roaring": "./scripts/update-roaring.sh",
"build-dev": "node ./scripts/build.js --dev",
"test": "node ./scripts/test.js",
"lint": "eslint .",
"lint:fix": "eslint . --fix && prettier --write .",
"lint": "eslint . && tsc",
"lint:fix": "eslint . --fix && prettier --write . && tsc",
"doc": "typedoc ./index.d.ts",
"benchmarks": "node --expose-gc ./scripts/benchmarks.js"
},
Expand Down
2 changes: 1 addition & 1 deletion test/RoaringBitmap32/RoaringBitmap32.basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -906,7 +906,7 @@ describe("RoaringBitmap32 basic", () => {
});

it("implements Set<> interface properly", () => {
const x: Set<number> = new RoaringBitmap32([1, 3]);
const x = new RoaringBitmap32([1, 3]);
x.add(2);
expect(x.has(2)).eq(true);
expect(Array.from(x.entries())).to.deep.equal([
Expand Down
Loading

0 comments on commit fdaf825

Please sign in to comment.