UNPKG

@atproto/repo

Version:

atproto repo and MST implementation

48 lines 1.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CidSet = void 0; const multiformats_1 = require("multiformats"); class CidSet { constructor(arr = []) { Object.defineProperty(this, "set", { enumerable: true, configurable: true, writable: true, value: void 0 }); const strArr = arr.map((c) => c.toString()); this.set = new Set(strArr); } add(cid) { this.set.add(cid.toString()); return this; } addSet(toMerge) { toMerge.toList().map((c) => this.add(c)); return this; } subtractSet(toSubtract) { toSubtract.toList().map((c) => this.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 [...this.set].map((c) => multiformats_1.CID.parse(c)); } } exports.CidSet = CidSet; exports.default = CidSet; //# sourceMappingURL=cid-set.js.map