Path: blob/master/src/packages/sync/editor/string/test/ephemeral-syncstring.ts
1451 views
/*1This is useful not just for testing, but also for implementing undo/redo for2editing a text document when there is no actual file or project involved.3*/45import { Client } from "./client-test";6import { SyncString } from "../sync";7import { a_txt } from "./data";8import { once } from "@cocalc/util/async-utils";910export default async function ephemeralSyncstring() {11const { client_id, project_id, path, init_queries } = a_txt();12const client = new Client(init_queries, client_id);13const syncstring = new SyncString({14project_id,15path,16client,17ephemeral: true,18});19// replace save to disk, since otherwise unless string is empty,20// this will hang forever... and it is called on close.21// @ts-ignore22syncstring.save_to_disk = async () => Promise<void>;23await once(syncstring, "ready");24return syncstring;25}262728