diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 62ca882..edfe600 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 3de1761..64f3140 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -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 diff --git a/.vscode/settings.json b/.vscode/settings.json index c0ed746..17ebf59 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -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, diff --git a/index.d.ts b/index.d.ts index 1035197..7aa4d55 100644 --- a/index.d.ts +++ b/index.d.ts @@ -23,6 +23,21 @@ Roaring Bitmap 32 documentation at: https://salvatorepreviti.github.io/roaring-n import roaring = require("./"); +export interface ReadonlySetLike { + /** + * Despite its name, returns an iterator of the values in the set-like. + */ + keys(): Iterator; + /** + * @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; @@ -339,7 +354,8 @@ export enum FrozenViewFormat { export type FrozenViewFormatType = FrozenViewFormat | "unsafe_frozen_croaring" | "unsafe_frozen_portable"; -export interface ReadonlyRoaringBitmap32 extends ReadonlySet { +export interface ReadonlyRoaringBitmap32 + extends Omit, "forEach" | "keys" | "values" | "entries" | typeof Symbol.iterator> { /** * Property. Gets the number of items in the set (cardinality). * @@ -442,7 +458,7 @@ export interface ReadonlyRoaringBitmap32 extends ReadonlySet { * @returns {RoaringBitmap32Iterator} A new iterator * @memberof ReadonlyRoaringBitmap32 */ - entries(): IterableIterator<[number, number]>; + entries(): ReturnType["entries"]>; /** * Executes a function for each value in the set, in ascending order. @@ -1262,14 +1278,14 @@ export interface ReadonlyRoaringBitmap32 extends ReadonlySet { isDisjointFrom(other: ReadonlySetLike | ReadonlyRoaringBitmap32): boolean; } -export interface RoaringBitmap32 extends ReadonlyRoaringBitmap32, Set { +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; @@ -1681,7 +1697,7 @@ export interface RoaringBitmap32 extends ReadonlyRoaringBitmap32, Set { /** * @returns a new RoaringBitmap32 containing all the elements in this Set which are not also in the argument. */ - difference(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. @@ -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; @@ -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(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. @@ -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; diff --git a/package.json b/package.json index 411220a..5cf572b 100644 --- a/package.json +++ b/package.json @@ -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" }, diff --git a/test/RoaringBitmap32/RoaringBitmap32.basic.test.ts b/test/RoaringBitmap32/RoaringBitmap32.basic.test.ts index d778b04..e5cb5cb 100644 --- a/test/RoaringBitmap32/RoaringBitmap32.basic.test.ts +++ b/test/RoaringBitmap32/RoaringBitmap32.basic.test.ts @@ -906,7 +906,7 @@ describe("RoaringBitmap32 basic", () => { }); it("implements Set<> interface properly", () => { - const x: Set = 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([ diff --git a/test/RoaringBitmap32/RoaringBitmap32.set-methods.test.ts b/test/RoaringBitmap32/RoaringBitmap32.set-methods.test.ts index b4a9bc0..92a41e5 100644 --- a/test/RoaringBitmap32/RoaringBitmap32.set-methods.test.ts +++ b/test/RoaringBitmap32/RoaringBitmap32.set-methods.test.ts @@ -1,6 +1,32 @@ import RoaringBitmap32 from "../../RoaringBitmap32"; import { expect } from "chai"; +interface ReadonlySetLike { + /** + * Despite its name, returns an iterator of the values in the set-like. + */ + keys(): Iterator; + /** + * @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; +} + +const createSet = (values?: T[] | undefined) => + new Set(values) as Set & { + union(other: ReadonlySetLike): Set; + intersection(other: ReadonlySetLike): Set; + difference(other: ReadonlySetLike): Set; + symmetricDifference(other: ReadonlySetLike): Set; + isSubsetOf(other: ReadonlySetLike): boolean; + isSupersetOf(other: ReadonlySetLike): boolean; + isDisjointFrom(other: ReadonlySetLike): boolean; + }; + describe("RoaringBitmap32 comparisons", () => { describe("isSubsetOf", () => { describe("RoaringBitmap32 isSubsetOf RoaringBitmap32", () => { @@ -56,30 +82,30 @@ describe("RoaringBitmap32 comparisons", () => { describe("RoaringBitmap32 isSubsetOf Set", () => { it("returns true with an empty set", () => { const bitmap = new RoaringBitmap32(); - expect(bitmap.isSubsetOf(new Set())).eq(true); + expect(bitmap.isSubsetOf(createSet())).eq(true); }); it("returns true with another empty set", () => { const a = new RoaringBitmap32(); - const b = new Set(); + const b = createSet(); expect(a.isSubsetOf(b)).eq(true); }); it("returns true with another non empty set", () => { const a = new RoaringBitmap32(); - const b = new Set([1, 2, 3]); + const b = createSet([1, 2, 3]); expect(a.isSubsetOf(b)).eq(true); }); it("returns true for bitmap1 < bitmap2", () => { const a = new RoaringBitmap32([1, 2]); - const b = new Set([1, 2, 3]); + const b = createSet([1, 2, 3]); expect(a.isSubsetOf(b)).eq(true); }); it("returns true for bitmap1 == bitmap2", () => { const a = new RoaringBitmap32([1, 2, 3]); - const b = new Set([1, 2, 3]); + const b = createSet([1, 2, 3]); expect(a.isSubsetOf(b)).eq(true); }); @@ -90,7 +116,7 @@ describe("RoaringBitmap32 comparisons", () => { it("returns false for bitmap1 > bitmap2", () => { const a = new RoaringBitmap32([1, 3, 2]); - const b = new Set([1, 2]); + const b = createSet([1, 2]); expect(a.isSubsetOf(b)).eq(false); }); }); @@ -99,40 +125,40 @@ describe("RoaringBitmap32 comparisons", () => { describe("Set isSubsetOf RoaringBitmap32", () => { it("empty set returns true with an empty set", () => { const bitmap = new RoaringBitmap32(); - expect(bitmap.isSubsetOf(new Set())).eq(true); + expect(bitmap.isSubsetOf(createSet())).eq(true); }); it("empty set returns true with another empty set", () => { - const a = new Set(); + const a = createSet(); const b = new RoaringBitmap32(); expect(a.isSubsetOf(b)).eq(true); }); it("empty set returns true with another non empty set", () => { - const a = new Set(); + const a = createSet(); const b = new RoaringBitmap32([1, 2, 3]); expect(a.isSubsetOf(b)).eq(true); }); it("returns true for bitmap1 < bitmap2", () => { - const a = new Set([1, 2]); + const a = createSet([1, 2]); const b = new RoaringBitmap32([1, 2, 3]); expect(a.isSubsetOf(b)).eq(true); }); it("returns true for bitmap1 == bitmap2", () => { - const a = new Set([1, 2, 3]); + const a = createSet([1, 2, 3]); const b = new RoaringBitmap32([1, 2, 3]); expect(a.isSubsetOf(b)).eq(true); }); it("returns true for bitmap1 === bitmap1", () => { - const bitmap = new Set([1, 2, 3]); + const bitmap = createSet([1, 2, 3]); expect(bitmap.isSubsetOf(bitmap)).eq(true); }); it("returns false for bitmap1 > bitmap2", () => { - const a = new Set([1, 3, 2]); + const a = createSet([1, 3, 2]); const b = new RoaringBitmap32([1, 2]); expect(a.isSubsetOf(b)).eq(false); }); @@ -186,30 +212,30 @@ describe("RoaringBitmap32 comparisons", () => { describe("RoaringBitmap32 isSupersetOf Set", () => { it("returns true with an empty set", () => { const bitmap = new RoaringBitmap32(); - expect(bitmap.isSupersetOf(new Set())).eq(true); + expect(bitmap.isSupersetOf(createSet())).eq(true); }); it("returns true with another empty set", () => { const a = new RoaringBitmap32(); - const b = new Set(); + const b = createSet(); expect(a.isSupersetOf(b)).eq(true); }); it("returns true with another non empty set", () => { const a = new RoaringBitmap32([1, 2, 3]); - const b = new Set(); + const b = createSet(); expect(a.isSupersetOf(b)).eq(true); }); it("returns true for bitmap1 > bitmap2", () => { const a = new RoaringBitmap32([1, 2, 3]); - const b = new Set([1, 2]); + const b = createSet([1, 2]); expect(a.isSupersetOf(b)).eq(true); }); it("returns true for bitmap1 == bitmap2", () => { const a = new RoaringBitmap32([1, 2, 3]); - const b = new Set([1, 2, 3]); + const b = createSet([1, 2, 3]); expect(a.isSupersetOf(b)).eq(true); }); @@ -220,13 +246,13 @@ describe("RoaringBitmap32 comparisons", () => { it("returns false for bitmap1 < bitmap2", () => { const a = new RoaringBitmap32([1, 2]); - const b = new Set([1, 2, 3]); + const b = createSet([1, 2, 3]); expect(a.isSupersetOf(b)).eq(false); }); it("returns false for bitmap1 < bitmap2", () => { const a = new RoaringBitmap32([1, 2]); - const b = new Set([1, 2, "x"]); + const b = createSet([1, 2, "x"]); expect(a.isSupersetOf(b)).eq(false); }); }); @@ -235,40 +261,40 @@ describe("RoaringBitmap32 comparisons", () => { describe("Set isSupersetOf RoaringBitmap32", () => { it("empty set returns true with an empty set", () => { const bitmap = new RoaringBitmap32(); - expect(bitmap.isSupersetOf(new Set())).eq(true); + expect(bitmap.isSupersetOf(createSet())).eq(true); }); it("empty set returns true with another empty set", () => { - const a = new Set(); + const a = createSet(); const b = new RoaringBitmap32(); expect(a.isSupersetOf(b)).eq(true); }); it("empty set and not empty bitmap", () => { - const a = new Set([1, 2, 3]); + const a = createSet([1, 2, 3]); const b = new RoaringBitmap32(); expect(a.isSupersetOf(b)).eq(true); }); it("returns true for bitmap1 > bitmap2", () => { - const a = new Set([1, 2, 3]); + const a = createSet([1, 2, 3]); const b = new RoaringBitmap32([1, 2]); expect(a.isSupersetOf(b)).eq(true); }); it("returns true for bitmap1 == bitmap2", () => { - const a = new Set([1, 2, 3]); + const a = createSet([1, 2, 3]); const b = new RoaringBitmap32([1, 2, 3]); expect(a.isSupersetOf(b)).eq(true); }); it("returns true for bitmap1 === bitmap1", () => { - const bitmap = new Set([1, 2, 3]); + const bitmap = createSet([1, 2, 3]); expect(bitmap.isSupersetOf(bitmap)).eq(true); }); it("returns false for bitmap1 < bitmap2", () => { - const a = new Set([1, 2]); + const a = createSet([1, 2]); const b = new RoaringBitmap32([1, 2, 3]); expect(a.isSupersetOf(b)).eq(false); }); @@ -322,30 +348,30 @@ describe("RoaringBitmap32 comparisons", () => { describe("RoaringBitmap32 isDisjointFrom Set", () => { it("returns true with an empty set", () => { const bitmap = new RoaringBitmap32(); - expect(bitmap.isDisjointFrom(new Set())).eq(true); + expect(bitmap.isDisjointFrom(createSet())).eq(true); }); it("returns true with another empty set", () => { const a = new RoaringBitmap32(); - const b = new Set(); + const b = createSet(); expect(a.isDisjointFrom(b)).eq(true); }); it("returns true with another non empty set", () => { const a = new RoaringBitmap32([1, 2, 3]); - const b = new Set(); + const b = createSet(); expect(a.isDisjointFrom(b)).eq(true); }); it("returns true for bitmap1 > bitmap2", () => { const a = new RoaringBitmap32([1, 2, 3]); - const b = new Set([4, 5]); + const b = createSet([4, 5]); expect(a.isDisjointFrom(b)).eq(true); }); it("returns true for bitmap1 == bitmap2", () => { const a = new RoaringBitmap32([1, 2, 3]); - const b = new Set([1, 2, 3]); + const b = createSet([1, 2, 3]); expect(a.isDisjointFrom(b)).eq(false); }); @@ -356,13 +382,13 @@ describe("RoaringBitmap32 comparisons", () => { it("returns false for bitmap1 < bitmap2", () => { const a = new RoaringBitmap32([1, 2]); - const b = new Set([1, 2, 3]); + const b = createSet([1, 2, 3]); expect(a.isDisjointFrom(b)).eq(false); }); it("returns false for bitmap1 < bitmap2", () => { const a = new RoaringBitmap32([1, 2]); - const b = new Set([1, 2, "x"]); + const b = createSet([1, 2, "x"]); expect(a.isDisjointFrom(b)).eq(false); }); }); @@ -371,40 +397,40 @@ describe("RoaringBitmap32 comparisons", () => { describe("Set isDisjointFrom RoaringBitmap32", () => { it("empty set returns true with an empty set", () => { const bitmap = new RoaringBitmap32(); - expect(bitmap.isDisjointFrom(new Set())).eq(true); + expect(bitmap.isDisjointFrom(createSet())).eq(true); }); it("empty set returns true with another empty set", () => { - const a = new Set(); + const a = createSet(); const b = new RoaringBitmap32(); expect(a.isDisjointFrom(b)).eq(true); }); it("empty set and not empty bitmap", () => { - const a = new Set([1, 2, 3]); + const a = createSet([1, 2, 3]); const b = new RoaringBitmap32(); expect(a.isDisjointFrom(b)).eq(true); }); it("returns true for bitmap1 > bitmap2", () => { - const a = new Set([1, 2, 3]); + const a = createSet([1, 2, 3]); const b = new RoaringBitmap32([4, 5]); expect(a.isDisjointFrom(b)).eq(true); }); it("returns true for bitmap1 == bitmap2", () => { - const a = new Set([1, 2, 3]); + const a = createSet([1, 2, 3]); const b = new RoaringBitmap32([1, 2, 3]); expect(a.isDisjointFrom(b)).eq(false); }); it("returns true for bitmap1 === bitmap1", () => { - const bitmap = new Set([1, 2, 3]); + const bitmap = createSet([1, 2, 3]); expect(bitmap.isDisjointFrom(bitmap)).eq(false); }); it("returns false for bitmap1 < bitmap2", () => { - const a = new Set([1, 2]); + const a = createSet([1, 2]); const b = new RoaringBitmap32([1, 2, 3]); expect(a.isDisjointFrom(b)).eq(false); }); @@ -450,7 +476,7 @@ describe("RoaringBitmap32 comparisons", () => { describe("RoaringBitmap32 union Set", () => { it("returns the union of an empty RoaringBitmap32 with an empty Set", () => { const a = new RoaringBitmap32(); - const b = new Set(); + const b = createSet(); const result = a.union(b); expect(result).to.be.instanceOf(Set); expect(Array.from(result)).deep.eq([]); @@ -458,7 +484,7 @@ describe("RoaringBitmap32 comparisons", () => { it("returns the union of a non empty RoaringBitmap32 with an empty Set", () => { const a = new RoaringBitmap32([1, 2, 3]); - const b = new Set(); + const b = createSet(); const result = a.union(b); expect(result).to.be.instanceOf(Set); expect(Array.from(result)).deep.eq([1, 2, 3]); @@ -466,7 +492,7 @@ describe("RoaringBitmap32 comparisons", () => { it("returns the union of two non empty RoaringBitmap32", () => { const a = new RoaringBitmap32([1, 2, 3]); - const b = new Set([2, 3, 4]); + const b = createSet([2, 3, 4]); const result = a.union(b); expect(result).to.be.instanceOf(Set); expect(Array.from(result)).deep.eq([1, 2, 3, 4]); @@ -474,7 +500,7 @@ describe("RoaringBitmap32 comparisons", () => { it("returns the union of two non empty RoaringBitmap32 with the same values", () => { const a = new RoaringBitmap32([1, 2, 3]); - const b = new Set([1, 2, 3]); + const b = createSet([1, 2, 3]); const result = a.union(b); expect(result).to.be.instanceOf(Set); expect(Array.from(result)).deep.eq([1, 2, 3]); @@ -484,7 +510,7 @@ describe("RoaringBitmap32 comparisons", () => { if ("union" in Set.prototype) { describe("Set union RoaringBitmap32", () => { it("returns the union of an empty Set with an empty RoaringBitmap32", () => { - const a = new Set(); + const a = createSet(); const b = new RoaringBitmap32(); const result = a.union(b); expect(result).to.be.instanceOf(Set); @@ -492,7 +518,7 @@ describe("RoaringBitmap32 comparisons", () => { }); it("returns the union of a non empty Set with an empty RoaringBitmap32", () => { - const a = new Set([1, 2, 3]); + const a = createSet([1, 2, 3]); const b = new RoaringBitmap32(); const result = a.union(b); expect(result).to.be.instanceOf(Set); @@ -500,7 +526,7 @@ describe("RoaringBitmap32 comparisons", () => { }); it("returns the union of two non empty Set", () => { - const a = new Set([1, 2, 3]); + const a = createSet([1, 2, 3]); const b = new RoaringBitmap32([2, 3, 4]); const result = a.union(b); expect(result).to.be.instanceOf(Set); @@ -508,7 +534,7 @@ describe("RoaringBitmap32 comparisons", () => { }); it("returns the union of two non empty Set with the same values", () => { - const a = new Set([1, 2, 3]); + const a = createSet([1, 2, 3]); const b = new RoaringBitmap32([1, 2, 3]); const result = a.union(b); expect(result).to.be.instanceOf(Set); @@ -556,7 +582,7 @@ describe("RoaringBitmap32 comparisons", () => { describe("RoaringBitmap32 intersection Set", () => { it("returns the intersection of an empty RoaringBitmap32 with an empty Set", () => { const a = new RoaringBitmap32(); - const b = new Set(); + const b = createSet(); const result = a.intersection(b); expect(result).to.be.instanceOf(Set); expect(Array.from(result)).deep.eq([]); @@ -564,7 +590,7 @@ describe("RoaringBitmap32 comparisons", () => { it("returns the intersection of a non empty RoaringBitmap32 with an empty Set", () => { const a = new RoaringBitmap32([1, 2, 3]); - const b = new Set(); + const b = createSet(); const result = a.intersection(b); expect(result).to.be.instanceOf(Set); expect(Array.from(result)).deep.eq([]); @@ -572,7 +598,7 @@ describe("RoaringBitmap32 comparisons", () => { it("returns the intersection of two non empty RoaringBitmap32", () => { const a = new RoaringBitmap32([1, 2, 3]); - const b = new Set([2, 3, 4]); + const b = createSet([2, 3, 4]); const result = a.intersection(b); expect(result).to.be.instanceOf(Set); expect(Array.from(result)).deep.eq([2, 3]); @@ -580,7 +606,7 @@ describe("RoaringBitmap32 comparisons", () => { it("returns the intersection of two non empty RoaringBitmap32 with the same values", () => { const a = new RoaringBitmap32([1, 2, 3]); - const b = new Set([1, 2, 3]); + const b = createSet([1, 2, 3]); const result = a.intersection(b); expect(result).to.be.instanceOf(Set); expect(Array.from(result)).deep.eq([1, 2, 3]); @@ -588,7 +614,7 @@ describe("RoaringBitmap32 comparisons", () => { it("returns the intersection of two non empty RoaringBitmap32 with the same values", () => { const a = new RoaringBitmap32([1, 2, 3]); - const b = new Set([1, 2, 3, 4]); + const b = createSet([1, 2, 3, 4]); const result = a.intersection(b); expect(result).to.be.instanceOf(Set); expect(Array.from(result)).deep.eq([1, 2, 3]); @@ -598,7 +624,7 @@ describe("RoaringBitmap32 comparisons", () => { if ("intersection" in Set.prototype) { describe("Set intersection RoaringBitmap32", () => { it("returns the intersection of an empty Set with an empty RoaringBitmap32", () => { - const a = new Set(); + const a = createSet(); const b = new RoaringBitmap32(); const result = a.intersection(b); expect(result).to.be.instanceOf(Set); @@ -606,7 +632,7 @@ describe("RoaringBitmap32 comparisons", () => { }); it("returns the intersection of a non empty Set with an empty RoaringBitmap32", () => { - const a = new Set([1, 2, 3]); + const a = createSet([1, 2, 3]); const b = new RoaringBitmap32(); const result = a.intersection(b); expect(result).to.be.instanceOf(Set); @@ -614,7 +640,7 @@ describe("RoaringBitmap32 comparisons", () => { }); it("returns the intersection of two non empty Set", () => { - const a = new Set([1, 2, 3]); + const a = createSet([1, 2, 3]); const b = new RoaringBitmap32([2, 3, 4]); const result = a.intersection(b); expect(result).to.be.instanceOf(Set); @@ -622,7 +648,7 @@ describe("RoaringBitmap32 comparisons", () => { }); it("returns the intersection of two non empty Set with the same values", () => { - const a = new Set([1, 2, 3]); + const a = createSet([1, 2, 3]); const b = new RoaringBitmap32([1, 2, 3]); const result = a.intersection(b); expect(result).to.be.instanceOf(Set); @@ -630,7 +656,7 @@ describe("RoaringBitmap32 comparisons", () => { }); it("returns the intersection of two non empty Set with the same values", () => { - const a = new Set([1, 2, 3]); + const a = createSet([1, 2, 3]); const b = new RoaringBitmap32([1, 2, 3, 4]); const result = a.intersection(b); expect(result).to.be.instanceOf(Set); @@ -678,7 +704,7 @@ describe("RoaringBitmap32 comparisons", () => { describe("RoaringBitmap32 difference Set", () => { it("returns the difference of an empty RoaringBitmap32 with an empty Set", () => { const a = new RoaringBitmap32(); - const b = new Set(); + const b = createSet(); const result = a.difference(b); expect(result).to.be.instanceOf(Set); expect(Array.from(result)).deep.eq([]); @@ -686,7 +712,7 @@ describe("RoaringBitmap32 comparisons", () => { it("returns the difference of a non empty RoaringBitmap32 with an empty Set", () => { const a = new RoaringBitmap32([1, 2, 3]); - const b = new Set(); + const b = createSet(); const result = a.difference(b); expect(result).to.be.instanceOf(Set); expect(Array.from(result)).deep.eq([1, 2, 3]); @@ -694,7 +720,7 @@ describe("RoaringBitmap32 comparisons", () => { it("returns the difference of two non empty RoaringBitmap32", () => { const a = new RoaringBitmap32([1, 2, 3]); - const b = new Set([2, 3, 4]); + const b = createSet([2, 3, 4]); const result = a.difference(b); expect(result).to.be.instanceOf(Set); expect(Array.from(result)).deep.eq([1]); @@ -702,7 +728,7 @@ describe("RoaringBitmap32 comparisons", () => { it("returns the difference of two non empty RoaringBitmap32 with the same values", () => { const a = new RoaringBitmap32([1, 2, 3]); - const b = new Set([1, 2, 3]); + const b = createSet([1, 2, 3]); const result = a.difference(b); expect(result).to.be.instanceOf(Set); expect(Array.from(result)).deep.eq([]); @@ -712,7 +738,7 @@ describe("RoaringBitmap32 comparisons", () => { if ("intersection" in Set.prototype) { describe("Set difference RoaringBitmap32", () => { it("returns the difference of an empty Set with an empty RoaringBitmap32", () => { - const a = new Set(); + const a = createSet(); const b = new RoaringBitmap32(); const result = a.difference(b); expect(result).to.be.instanceOf(Set); @@ -720,7 +746,7 @@ describe("RoaringBitmap32 comparisons", () => { }); it("returns the difference of a non empty Set with an empty RoaringBitmap32", () => { - const a = new Set([1, 2, 3]); + const a = createSet([1, 2, 3]); const b = new RoaringBitmap32(); const result = a.difference(b); expect(result).to.be.instanceOf(Set); @@ -728,7 +754,7 @@ describe("RoaringBitmap32 comparisons", () => { }); it("returns the difference of two non empty Set", () => { - const a = new Set([1, 2, 3]); + const a = createSet([1, 2, 3]); const b = new RoaringBitmap32([2, 3, 4]); const result = a.difference(b); expect(result).to.be.instanceOf(Set); @@ -736,7 +762,7 @@ describe("RoaringBitmap32 comparisons", () => { }); it("returns the difference of two non empty Set with the same values", () => { - const a = new Set([1, 2, 3]); + const a = createSet([1, 2, 3]); const b = new RoaringBitmap32([1, 2, 3]); const result = a.difference(b); expect(result).to.be.instanceOf(Set); @@ -784,7 +810,7 @@ describe("RoaringBitmap32 comparisons", () => { describe("RoaringBitmap32 symmetricDifference Set", () => { it("returns the symmetricDifference of an empty RoaringBitmap32 with an empty Set", () => { const a = new RoaringBitmap32(); - const b = new Set(); + const b = createSet(); const result = a.symmetricDifference(b); expect(result).to.be.instanceOf(Set); expect(Array.from(result)).deep.eq([]); @@ -792,7 +818,7 @@ describe("RoaringBitmap32 comparisons", () => { it("returns the symmetricDifference of a non empty RoaringBitmap32 with an empty Set", () => { const a = new RoaringBitmap32([1, 2, 3]); - const b = new Set(); + const b = createSet(); const result = a.symmetricDifference(b); expect(result).to.be.instanceOf(Set); expect(Array.from(result)).deep.eq([1, 2, 3]); @@ -800,7 +826,7 @@ describe("RoaringBitmap32 comparisons", () => { it("returns the symmetricDifference of two non empty RoaringBitmap32", () => { const a = new RoaringBitmap32([1, 2, 3]); - const b = new Set([2, 3, 4]); + const b = createSet([2, 3, 4]); const result = a.symmetricDifference(b); expect(result).to.be.instanceOf(Set); expect(Array.from(result)).deep.eq([1, 4]); @@ -808,7 +834,7 @@ describe("RoaringBitmap32 comparisons", () => { it("returns the symmetricDifference of two non empty RoaringBitmap32 with the same values", () => { const a = new RoaringBitmap32([1, 2, 3]); - const b = new Set([1, 2, 3]); + const b = createSet([1, 2, 3]); const result = a.symmetricDifference(b); expect(result).to.be.instanceOf(Set); expect(Array.from(result)).deep.eq([]); @@ -818,7 +844,7 @@ describe("RoaringBitmap32 comparisons", () => { if ("symmetricDifference" in Set.prototype) { describe("Set symmetricDifference RoaringBitmap32", () => { it("returns the symmetricDifference of an empty Set with an empty RoaringBitmap32", () => { - const a = new Set(); + const a = createSet(); const b = new RoaringBitmap32(); const result = a.symmetricDifference(b); expect(result).to.be.instanceOf(Set); @@ -826,7 +852,7 @@ describe("RoaringBitmap32 comparisons", () => { }); it("returns the symmetricDifference of a non empty Set with an empty RoaringBitmap32", () => { - const a = new Set([1, 2, 3]); + const a = createSet([1, 2, 3]); const b = new RoaringBitmap32(); const result = a.symmetricDifference(b); expect(result).to.be.instanceOf(Set); @@ -834,7 +860,7 @@ describe("RoaringBitmap32 comparisons", () => { }); it("returns the symmetricDifference of two non empty Set", () => { - const a = new Set([1, 2, 3]); + const a = createSet([1, 2, 3]); const b = new RoaringBitmap32([2, 3, 4]); const result = a.symmetricDifference(b); expect(result).to.be.instanceOf(Set); @@ -842,7 +868,7 @@ describe("RoaringBitmap32 comparisons", () => { }); it("returns the symmetricDifference of two non empty Set with the same values", () => { - const a = new Set([1, 2, 3]); + const a = createSet([1, 2, 3]); const b = new RoaringBitmap32([1, 2, 3]); const result = a.symmetricDifference(b); expect(result).to.be.instanceOf(Set);