UNPKG

universal-fs

Version:

Allows a client or server to access the file system in the current codebase or a different one.

14 lines (11 loc) 335 B
import {isBrowser, isNode} from "browser-or-node"; import getCookie from "./getCookie"; const getTokenSync = async () => { if (isBrowser) { return getCookie("universal-fs-token"); } else if (isNode) { const fs = await import("fs"); return fs.readFileSync(".fs/token.txt", "utf8"); } }; export default getTokenSync;