UNPKG

@atproto/repo

Version:

atproto repo and MST implementation

45 lines 1.01 kB
import { parseCid } from '@atproto/lex-data'; export class CidSet { constructor(arr = []) { const strArr = arr.map((c) => c.toString()); this.set = new Set(strArr); } add(cid) { this.set.add(cid.toString()); return this; } addSet(toMerge) { for (const c of toMerge.set) this.set.add(c); return this; } subtractSet(toSubtract) { for (const c of toSubtract.set) this.set.delete(c); return this; } delete(cid) { this.set.delete(cid.toString()); return this; } has(cid) { return this.set.has(cid.toString()); } size() { return this.set.size; } clear() { this.set.clear(); return this; } toList() { return Array.from(this); } *[Symbol.iterator]() { for (const c of this.set) { yield parseCid(c); } } } export default CidSet; //# sourceMappingURL=cid-set.js.map