@daaku/kombat
Advanced tools
Comparing version 2.2.0 to 2.3.0
@@ -1,7 +0,1 @@ | ||
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { | ||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); | ||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); | ||
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); | ||
}; | ||
var _SyncDB_pending; | ||
import { customAlphabet } from 'nanoid'; | ||
@@ -13,5 +7,5 @@ import { murmurHashV3 } from './murmurhash.js'; | ||
class ClockDriftError extends Error { | ||
type = 'ClockDriftError'; | ||
constructor(context) { | ||
super(); | ||
this.type = 'ClockDriftError'; | ||
this.message = `clock drift exceeded limit: ${context}`; | ||
@@ -21,5 +15,5 @@ } | ||
class CounterOverflowError extends Error { | ||
type = 'CounterOverflowError'; | ||
constructor() { | ||
super(); | ||
this.type = 'CounterOverflowError'; | ||
this.message = 'timestamp counter overflow'; | ||
@@ -29,5 +23,5 @@ } | ||
class InvalidTimestampError extends Error { | ||
type = 'InvalidTimestampError'; | ||
constructor(input) { | ||
super(); | ||
this.type = 'InvalidTimestampError'; | ||
this.message = `timestamp format invalid: ${input}`; | ||
@@ -38,2 +32,5 @@ } | ||
export class Timestamp { | ||
millis; | ||
counter; | ||
nodeID; | ||
constructor(millis, counter, nodeID) { | ||
@@ -87,2 +84,4 @@ this.millis = millis; | ||
export class Merkle { | ||
hash; | ||
children; | ||
constructor(hash = 0, children = {}) { | ||
@@ -158,2 +157,5 @@ this.hash = hash; | ||
export class Clock { | ||
timestamp; | ||
merkle; | ||
maxDriftMS; | ||
constructor(timestamp, merkle, maxDriftMS) { | ||
@@ -226,2 +228,7 @@ this.timestamp = timestamp || new Timestamp(0, 0, nanoid()); | ||
export class SyncDB { | ||
clock; | ||
remote; | ||
local; | ||
nextSync; | ||
#pending = new Set(); | ||
constructor(clock, remote, local) { | ||
@@ -231,3 +238,2 @@ this.clock = clock; | ||
this.local = local; | ||
_SyncDB_pending.set(this, new Set()); | ||
} | ||
@@ -300,4 +306,4 @@ // Create a new instance of a SyncDB. | ||
const r = this.sync(); | ||
__classPrivateFieldGet(this, _SyncDB_pending, "f").add(r); | ||
r.finally(() => __classPrivateFieldGet(this, _SyncDB_pending, "f").delete(r)); | ||
this.#pending.add(r); | ||
r.finally(() => this.#pending.delete(r)); | ||
}, timeoutMS); | ||
@@ -341,6 +347,5 @@ } | ||
async settle() { | ||
await Promise.allSettled(__classPrivateFieldGet(this, _SyncDB_pending, "f").values()); | ||
await Promise.allSettled(this.#pending.values()); | ||
} | ||
} | ||
_SyncDB_pending = new WeakMap(); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@daaku/kombat", | ||
"author": "Naitik Shah <n@daaku.org>", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"description": "Infrastructure for CRDT powered applications.", | ||
@@ -6,0 +6,0 @@ "repository": "git@github.com:daaku/kombat", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
478
34009