/ examples / _persisted-session.ts
_persisted-session.ts
 1  import type { Identification } from "../src";
 2  
 3  import fs from "node:fs/promises";
 4  import path from "node:path";
 5  
 6  const json = path.join(__dirname, "_persisted-session.json");
 7  
 8  export const persist = async (identification: Identification): Promise<void> => {
 9    await fs.writeFile(json, JSON.stringify(identification), "utf8");
10  };
11  
12  export const read = async (): Promise<Identification> => {
13    const data = await fs.readFile(json, "utf8");
14    return JSON.parse(data);
15  };