diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2020-03-22 01:43:54 +0100 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2020-03-22 01:43:54 +0100 |
commit | 6484d42dabf1482e2ea538d2512537690180b8d2 (patch) | |
tree | fa9b6fb59361ababa8ccc9e4f58a8f34029f0f8d /src/renderer/editor/util.ts | |
parent | 1605e743f44b835e99b3403cb3cfc5018b697d26 (diff) | |
download | rpgedit-6484d42dabf1482e2ea538d2512537690180b8d2.tar rpgedit-6484d42dabf1482e2ea538d2512537690180b8d2.zip |
editor: list tiles in project directory
Diffstat (limited to 'src/renderer/editor/util.ts')
-rw-r--r-- | src/renderer/editor/util.ts | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/renderer/editor/util.ts b/src/renderer/editor/util.ts index b2331bb..f816de4 100644 --- a/src/renderer/editor/util.ts +++ b/src/renderer/editor/util.ts @@ -25,7 +25,12 @@ export function usePromise<T>(f: () => Promise<T>): T | null { return value; } -export function useReadFile(path: string, encoding: BufferEncoding): string | null { - const readFile = useCallback(() => fs.promises.readFile(path, encoding), [path, encoding]); +export function useReadFile(path: string): Buffer | null { + const readFile = useCallback(() => fs.promises.readFile(path), [path]); return usePromise(readFile); } + +export async function readJSON(path: string): Promise<unknown> { + const content = await fs.promises.readFile(path, 'utf8'); + return JSON.parse(content); +} |