import type { Key, Range } from '../interfaces/common.js'; import type { AztecAsyncSet } from '../interfaces/set.js'; import { SQLiteOPFSAztecMap } from './map.js'; import type { AztecSQLiteOPFSStore } from './store.js'; /** Set backed by SQLite. Composes a Map. */ export class SQLiteOPFSAztecSet implements AztecAsyncSet { readonly #map: SQLiteOPFSAztecMap; constructor(store: AztecSQLiteOPFSStore, name: string) { this.#map = new SQLiteOPFSAztecMap(store, name); } hasAsync(key: K): Promise { return this.#map.hasAsync(key); } add(key: K): Promise { return this.#map.set(key, true); } delete(key: K): Promise { return this.#map.delete(key); } async *entriesAsync(range: Range = {}): AsyncIterableIterator { yield* this.#map.keysAsync(range); } }