示例工程 37-local-persistence
37-local-persistence/app/.tsc/shared/json-store.d.ts
export type Note = {
id: string;
title: string;
body: string;
tags: string[];
updatedAt: string;
};
export type JsonDoc = {
version: 1;
updatedAt: string;
items: Note[];
};
export type JsonSource = "main" | "backup" | "fallback" | "seed";
export type ReadResult = {
doc: JsonDoc;
source: JsonSource;
error: string;
readMs: number;
};
export declare function jsonFile(dir: string): string;
export declare function backupFile(dir: string): string;
export declare function seedNotes(): Note[];
export declare function emptyDoc(): JsonDoc;
export declare function isJsonDoc(value: unknown): value is JsonDoc;
export declare function atomicWriteText(file: string, text: string): number;
export declare function writeJsonStore(dir: string, doc: JsonDoc): {
bytes: number;
writeMs: number;
};
export declare function readJsonStore(dir: string): ReadResult;
export declare function jsonStoreSize(dir: string): number;
//# sourceMappingURL=json-store.d.ts.map