From a1dd803be688f42d144371bf5fffe4091f54ddaf Mon Sep 17 00:00:00 2001 From: James Prevett Date: Mon, 11 Nov 2024 18:15:17 -0600 Subject: [PATCH] Add interface for `Async` mixin --- src/mixins/async.ts | 48 +++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/src/mixins/async.ts b/src/mixins/async.ts index 0508c08b..a6848e00 100644 --- a/src/mixins/async.ts +++ b/src/mixins/async.ts @@ -12,6 +12,28 @@ export type AsyncOperation = { [K in keyof AsyncFSMethods]: [K, ...Parameters]; }[keyof AsyncFSMethods]; +/** + * @internal + */ +export interface Async { + /** + * @internal @protected + */ + _sync?: FileSystem; + queueDone(): Promise; + ready(): Promise; + renameSync(oldPath: string, newPath: string): void; + statSync(path: string): Stats; + createFileSync(path: string, flag: string, mode: number): File; + openFileSync(path: string, flag: string): File; + unlinkSync(path: string): void; + rmdirSync(path: string): void; + mkdirSync(path: string, mode: number): void; + readdirSync(path: string): string[]; + linkSync(srcpath: string, dstpath: string): void; + syncSync(path: string, data: Uint8Array, stats: Readonly): void; +} + /** * Async() implements synchronous methods on an asynchronous file system * @@ -22,29 +44,7 @@ export type AsyncOperation = { * During loading, the contents of the async file system are preloaded into the synchronous store. * */ -export function Async( - FS: T -): Mixin< - T, - { - /** - * @internal @protected - */ - _sync?: FileSystem; - queueDone(): Promise; - ready(): Promise; - renameSync(oldPath: string, newPath: string): void; - statSync(path: string): Stats; - createFileSync(path: string, flag: string, mode: number): File; - openFileSync(path: string, flag: string): File; - unlinkSync(path: string): void; - rmdirSync(path: string): void; - mkdirSync(path: string, mode: number): void; - readdirSync(path: string): string[]; - linkSync(srcpath: string, dstpath: string): void; - syncSync(path: string, data: Uint8Array, stats: Readonly): void; - } -> { +export function Async(FS: T): Mixin { abstract class AsyncFS extends FS { /** * Queue of pending asynchronous operations. @@ -226,3 +226,5 @@ export function Async( return AsyncFS; } + +export function asyncPatch(fs: Mixin) {}