UNPKG

@synet/net

Version:

Network abstraction layer for Synet. visit https://syntehtism.ai for more information.

36 lines (35 loc) 979 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MemFileSystem = void 0; const memfs_1 = require("memfs"); /** * In-memory file system implementation using memfs */ class MemFileSystem { async exists(path) { try { await memfs_1.fs.promises.stat(path); return true; } catch { return false; } } async readFile(path) { const buffer = await memfs_1.fs.promises.readFile(path); return buffer.toString("utf8"); } async writeFile(path, data) { await memfs_1.fs.promises.writeFile(path, data, { encoding: "utf8" }); } async deleteFile(path) { await memfs_1.fs.promises.unlink(path); } async ensureDir(path) { await memfs_1.fs.promises.mkdir(path, { recursive: true }); } async chmod(path, mode) { await memfs_1.fs.promises.chmod(path, mode); } } exports.MemFileSystem = MemFileSystem;