@daaku/kombat
Advanced tools
Comparing version 2.1.0 to 2.2.0
@@ -57,2 +57,3 @@ export declare class Timestamp { | ||
export declare class SyncDB { | ||
#private; | ||
private clock; | ||
@@ -70,3 +71,4 @@ private remote; | ||
send(messages: Omit<Message, 'timestamp'>[]): Promise<void>; | ||
settle(): Promise<void>; | ||
} | ||
export {}; |
@@ -0,1 +1,7 @@ | ||
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'; | ||
@@ -218,2 +224,3 @@ import { murmurHashV3 } from './murmurhash.js'; | ||
this.local = local; | ||
_SyncDB_pending.set(this, new Set()); | ||
} | ||
@@ -284,3 +291,7 @@ // Create a new instance of a SyncDB. | ||
} | ||
this.nextSync = setTimeout(() => this.sync(), timeoutMS); | ||
this.nextSync = setTimeout(() => { | ||
const r = this.sync(); | ||
__classPrivateFieldGet(this, _SyncDB_pending, "f").add(r); | ||
r.finally(() => __classPrivateFieldGet(this, _SyncDB_pending, "f").delete(r)); | ||
}, timeoutMS); | ||
} | ||
@@ -321,3 +332,8 @@ // Sync data to-and-from the Remote. | ||
} | ||
// Wait for scheduled sync to settle. | ||
async settle() { | ||
await Promise.allSettled(__classPrivateFieldGet(this, _SyncDB_pending, "f").values()); | ||
} | ||
} | ||
_SyncDB_pending = new WeakMap(); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@daaku/kombat", | ||
"author": "Naitik Shah <n@daaku.org>", | ||
"version": "2.1.0", | ||
"version": "2.2.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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
34467
473
0