Skip to content

Commit

Permalink
🤖 Merge PR DefinitelyTyped#70823 [sharedb] Add doc.toSnapshot() by @…
Browse files Browse the repository at this point in the history
  • Loading branch information
alecgibson authored Oct 15, 2024
1 parent c2b6304 commit 9c92d53
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion types/sharedb/lib/sharedb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface Snapshot<T = any> {
data?: T;
m: SnapshotMeta | null;
}
export type IngestibleSnapshot<T = any> = Pick<Snapshot<T>, "v" | "type" | "data">;

export interface SnapshotMeta {
ctime: number;
Expand Down Expand Up @@ -174,7 +175,8 @@ export class Doc<T = any> extends TypedEmitter<DocEventMap<T>> {
subscribe: (callback?: (err: Error) => void) => void;
unsubscribe: (callback?: (err: Error) => void) => void;

ingestSnapshot(snapshot: Pick<Snapshot<T>, "v" | "type" | "data">, callback?: Callback): void;
toSnapshot(): IngestibleSnapshot<T>;
ingestSnapshot(snapshot: IngestibleSnapshot<T>, callback?: Callback): void;
destroy(callback?: Callback): void;
create(data: T, callback?: Callback): void;
create(data: T, type?: string, callback?: Callback): void;
Expand Down
2 changes: 2 additions & 0 deletions types/sharedb/sharedb-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ doc.fetch((err) => {

doc.create({ foo: true }, "http://sharejs.org/types/JSONv0");

doc.ingestSnapshot(doc.toSnapshot());

function startServer() {
const server = http.createServer();

Expand Down

0 comments on commit 9c92d53

Please sign in to comment.