From 2f71cd4c08bb4514efe43533e6a5d03535204c29 Mon Sep 17 00:00:00 2001 From: Aylur Date: Tue, 15 Oct 2024 01:26:32 +0200 Subject: refactor lua and gjs lib --- core/gjs/src/file.ts | 44 -------------------------------------------- 1 file changed, 44 deletions(-) delete mode 100644 core/gjs/src/file.ts (limited to 'core/gjs/src/file.ts') diff --git a/core/gjs/src/file.ts b/core/gjs/src/file.ts deleted file mode 100644 index 90b33a1..0000000 --- a/core/gjs/src/file.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { Astal, Gio } from "./imports.js" - -export function readFile(path: string): string { - return Astal.read_file(path) || "" -} - -export function readFileAsync(path: string): Promise { - return new Promise((resolve, reject) => { - Astal.read_file_async(path, (_, res) => { - try { - resolve(Astal.read_file_finish(res) || "") - } - catch (error) { - reject(error) - } - }) - }) -} - -export function writeFile(path: string, content: string): void { - Astal.write_file(path, content) -} - -export function writeFileAsync(path: string, content: string): Promise { - return new Promise((resolve, reject) => { - Astal.write_file_async(path, content, (_, res) => { - try { - resolve(Astal.write_file_finish(res)) - } - catch (error) { - reject(error) - } - }) - }) -} - -export function monitorFile( - path: string, - callback: (file: string, event: Gio.FileMonitorEvent) => void, -): Gio.FileMonitor { - return Astal.monitor_file(path, (file: string, event: Gio.FileMonitorEvent) => { - callback(file, event) - })! -} -- cgit v1.2.3