UNPKG

@zenfs/core

Version:

A filesystem, anywhere

51 lines (50 loc) 1.5 kB
/** * Implements the asynchronous API in terms of the synchronous API. * @category Internals */ /* eslint-disable @typescript-eslint/require-await */ export function Sync(FS) { class SyncFS extends FS { async exists(path) { return this.existsSync(path); } async rename(oldPath, newPath) { return this.renameSync(oldPath, newPath); } async stat(path) { return this.statSync(path); } async touch(path, metadata) { return this.touchSync(path, metadata); } async createFile(path, options) { return this.createFileSync(path, options); } async unlink(path) { return this.unlinkSync(path); } async rmdir(path) { return this.rmdirSync(path); } async mkdir(path, options) { return this.mkdirSync(path, options); } async readdir(path) { return this.readdirSync(path); } async link(srcpath, dstpath) { return this.linkSync(srcpath, dstpath); } async sync() { return this.syncSync(); } async read(path, buffer, offset, end) { return this.readSync(path, buffer, offset, end); } async write(path, buffer, offset) { return this.writeSync(path, buffer, offset); } } return SyncFS; } /* eslint-enable @typescript-eslint/require-await */