-
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 🎸 setup fsa to node utility
- Loading branch information
Showing
3 changed files
with
265 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,261 @@ | ||
import type {FsCallbackApi} from '../node/types'; | ||
import type * as misc from '../node/types/misc'; | ||
import type * as opts from '../node/types/options'; | ||
import type * as fsa from '../fsa/types'; | ||
|
||
const notImplemented: ((...args: unknown[]) => unknown) = () => { | ||
throw new Error('Not implemented'); | ||
}; | ||
|
||
/** | ||
* Constructs a Node.js `fs` API from a File System Access API | ||
* [`FileSystemDirectoryHandle` object](https://developer.mozilla.org/en-US/docs/Web/API/FileSystemDirectoryHandle). | ||
*/ | ||
export class FsaNodeFs implements FsCallbackApi { | ||
public constructor (protected readonly root: fsa.IFileSystemDirectoryHandle) {} | ||
|
||
public readonly open: FsCallbackApi['open'] = (path: misc.PathLike, flags: misc.TFlags, a?: misc.TMode | misc.TCallback<number>, b?: misc.TCallback<number> | string) => { | ||
throw new Error('Not implemented'); | ||
}; | ||
|
||
public readonly close: FsCallbackApi['close'] = (fd: number, callback: misc.TCallback<void>): void => { | ||
throw new Error('Not implemented'); | ||
}; | ||
|
||
public readonly read: FsCallbackApi['read'] = ( | ||
fd: number, | ||
buffer: Buffer | ArrayBufferView | DataView, | ||
offset: number, | ||
length: number, | ||
position: number, | ||
callback: (err?: Error | null, bytesRead?: number, buffer?: Buffer | ArrayBufferView | DataView) => void, | ||
): void => { | ||
throw new Error('Not implemented'); | ||
}; | ||
|
||
public readonly readFile: FsCallbackApi['readFile'] = (id: misc.TFileId, a?: opts.IReadFileOptions | string | misc.TCallback<misc.TDataOut>, b?: misc.TCallback<misc.TDataOut>) => { | ||
throw new Error('Not implemented'); | ||
}; | ||
|
||
public readonly write: FsCallbackApi['write'] = (fd: number, a?, b?, c?, d?, e?) => { | ||
throw new Error('Not implemented'); | ||
}; | ||
|
||
writeFile(id: misc.TFileId, data: misc.TData, callback: misc.TCallback<void>); | ||
writeFile( | ||
id: misc.TFileId, | ||
data: misc.TData, | ||
options: opts.IWriteFileOptions | string, | ||
callback: misc.TCallback<void>, | ||
); | ||
writeFile(id: misc.TFileId, data: misc.TData, a: misc.TCallback<void> | opts.IWriteFileOptions | string, b?: misc.TCallback<void>) { | ||
throw new Error('Not implemented'); | ||
} | ||
|
||
copyFile(src: misc.PathLike, dest: misc.PathLike, callback: misc.TCallback<void>); | ||
copyFile(src: misc.PathLike, dest: misc.PathLike, flags: misc.TFlagsCopy, callback: misc.TCallback<void>); | ||
copyFile(src: misc.PathLike, dest: misc.PathLike, a, b?) { | ||
throw new Error('Not implemented'); | ||
} | ||
|
||
link(existingPath: misc.PathLike, newPath: misc.PathLike, callback: misc.TCallback<void>): void { | ||
throw new Error('Not implemented'); | ||
} | ||
|
||
unlink(path: misc.PathLike, callback: misc.TCallback<void>): void { | ||
throw new Error('Not implemented'); | ||
} | ||
|
||
symlink(target: misc.PathLike, path: misc.PathLike, callback: misc.TCallback<void>); | ||
symlink(target: misc.PathLike, path: misc.PathLike, type: misc.symlink.Type, callback: misc.TCallback<void>); | ||
symlink(target: misc.PathLike, path: misc.PathLike, a: misc.symlink.Type | misc.TCallback<void>, b?: misc.TCallback<void>) { | ||
throw new Error('Not implemented'); | ||
} | ||
|
||
realpath(path: misc.PathLike, callback: misc.TCallback<misc.TDataOut>); | ||
realpath(path: misc.PathLike, options: opts.IRealpathOptions | string, callback: misc.TCallback<misc.TDataOut>); | ||
realpath(path: misc.PathLike, a: misc.TCallback<misc.TDataOut> | opts.IRealpathOptions | string, b?: misc.TCallback<misc.TDataOut>) { | ||
throw new Error('Not implemented'); | ||
} | ||
|
||
lstat(path: misc.PathLike, callback: misc.TCallback<misc.IStats>): void; | ||
lstat(path: misc.PathLike, options: opts.IStatOptions, callback: misc.TCallback<misc.IStats>): void; | ||
lstat(path: misc.PathLike, a: misc.TCallback<misc.IStats> | opts.IStatOptions, b?: misc.TCallback<misc.IStats>): void { | ||
throw new Error('Not implemented'); | ||
} | ||
|
||
stat(path: misc.PathLike, callback: misc.TCallback<misc.IStats>): void; | ||
stat(path: misc.PathLike, options: opts.IStatOptions, callback: misc.TCallback<misc.IStats>): void; | ||
stat(path: misc.PathLike, a: misc.TCallback<misc.IStats> | opts.IStatOptions, b?: misc.TCallback<misc.IStats>): void { | ||
throw new Error('Not implemented'); | ||
} | ||
|
||
fstat(fd: number, callback: misc.TCallback<misc.IStats>): void; | ||
fstat(fd: number, options: opts.IFStatOptions, callback: misc.TCallback<misc.IStats>): void; | ||
fstat(fd: number, a: misc.TCallback<misc.IStats> | opts.IFStatOptions, b?: misc.TCallback<misc.IStats>): void { | ||
throw new Error('Not implemented'); | ||
} | ||
|
||
rename(oldPath: misc.PathLike, newPath: misc.PathLike, callback: misc.TCallback<void>): void { | ||
throw new Error('Not implemented'); | ||
} | ||
|
||
exists(path: misc.PathLike, callback: (exists: boolean) => void): void { | ||
throw new Error('Not implemented'); | ||
} | ||
|
||
access(path: misc.PathLike, callback: misc.TCallback<void>); | ||
access(path: misc.PathLike, mode: number, callback: misc.TCallback<void>); | ||
access(path: misc.PathLike, a: misc.TCallback<void> | number, b?: misc.TCallback<void>) { | ||
throw new Error('Not implemented'); | ||
} | ||
|
||
appendFile(id: misc.TFileId, data: misc.TData, callback: misc.TCallback<void>); | ||
appendFile( | ||
id: misc.TFileId, | ||
data: misc.TData, | ||
options: opts.IAppendFileOptions | string, | ||
callback: misc.TCallback<void>, | ||
); | ||
appendFile(id: misc.TFileId, data: misc.TData, a, b?) { | ||
throw new Error('Not implemented'); | ||
} | ||
|
||
readdir(path: misc.PathLike, callback: misc.TCallback<misc.TDataOut[] | misc.IDirent[]>); | ||
readdir( | ||
path: misc.PathLike, | ||
options: opts.IReaddirOptions | string, | ||
callback: misc.TCallback<misc.TDataOut[] | misc.IDirent[]>, | ||
); | ||
readdir(path: misc.PathLike, a?, b?) { | ||
throw new Error('Not implemented'); | ||
} | ||
|
||
readlink(path: misc.PathLike, callback: misc.TCallback<misc.TDataOut>); | ||
readlink(path: misc.PathLike, options: opts.IOptions, callback: misc.TCallback<misc.TDataOut>); | ||
readlink(path: misc.PathLike, a: misc.TCallback<misc.TDataOut> | opts.IOptions, b?: misc.TCallback<misc.TDataOut>) { | ||
throw new Error('Not implemented'); | ||
} | ||
|
||
fsyncSync(fd: number): void { | ||
throw new Error('Not implemented'); | ||
} | ||
|
||
fsync(fd: number, callback: misc.TCallback<void>): void { | ||
throw new Error('Not implemented'); | ||
} | ||
|
||
fdatasync(fd: number, callback: misc.TCallback<void>): void { | ||
throw new Error('Not implemented'); | ||
} | ||
|
||
ftruncate(fd: number, callback: misc.TCallback<void>); | ||
ftruncate(fd: number, len: number, callback: misc.TCallback<void>); | ||
ftruncate(fd: number, a: misc.TCallback<void> | number, b?: misc.TCallback<void>) { | ||
throw new Error('Not implemented'); | ||
} | ||
|
||
truncate(id: misc.TFileId, callback: misc.TCallback<void>); | ||
truncate(id: misc.TFileId, len: number, callback: misc.TCallback<void>); | ||
truncate(id: misc.TFileId, a: misc.TCallback<void> | number, b?: misc.TCallback<void>) { | ||
throw new Error('Not implemented'); | ||
} | ||
|
||
futimes(fd: number, atime: misc.TTime, mtime: misc.TTime, callback: misc.TCallback<void>): void { | ||
throw new Error('Not implemented'); | ||
} | ||
|
||
utimes(path: misc.PathLike, atime: misc.TTime, mtime: misc.TTime, callback: misc.TCallback<void>): void { | ||
throw new Error('Not implemented'); | ||
} | ||
|
||
mkdir(path: misc.PathLike, callback: misc.TCallback<void>); | ||
mkdir( | ||
path: misc.PathLike, | ||
mode: misc.TMode | (opts.IMkdirOptions & { recursive?: false }), | ||
callback: misc.TCallback<void>, | ||
); | ||
mkdir(path: misc.PathLike, mode: opts.IMkdirOptions & { recursive: true }, callback: misc.TCallback<string>); | ||
mkdir(path: misc.PathLike, mode: misc.TMode | opts.IMkdirOptions, callback: misc.TCallback<string>); | ||
mkdir(path: misc.PathLike, a: misc.TCallback<void> | misc.TMode | opts.IMkdirOptions, b?: misc.TCallback<string> | misc.TCallback<void>) { | ||
throw new Error('Not implemented'); | ||
} | ||
|
||
mkdirp(path: misc.PathLike, callback: misc.TCallback<string>); | ||
mkdirp(path: misc.PathLike, mode: misc.TMode, callback: misc.TCallback<string>); | ||
mkdirp(path: misc.PathLike, a: misc.TCallback<string> | misc.TMode, b?: misc.TCallback<string>) { | ||
throw new Error('Not implemented'); | ||
} | ||
|
||
mkdtemp(prefix: string, callback: misc.TCallback<void>): void; | ||
mkdtemp(prefix: string, options: opts.IOptions, callback: misc.TCallback<void>); | ||
mkdtemp(prefix: string, a: misc.TCallback<void> | opts.IOptions, b?: misc.TCallback<void>) { | ||
throw new Error('Not implemented'); | ||
} | ||
|
||
rmdir(path: misc.PathLike, callback: misc.TCallback<void>); | ||
rmdir(path: misc.PathLike, options: opts.IRmdirOptions, callback: misc.TCallback<void>); | ||
rmdir(path: misc.PathLike, a: misc.TCallback<void> | opts.IRmdirOptions, b?: misc.TCallback<void>) { | ||
throw new Error('Not implemented'); | ||
} | ||
|
||
rm(path: misc.PathLike, callback: misc.TCallback<void>): void; | ||
rm(path: misc.PathLike, options: opts.IRmOptions, callback: misc.TCallback<void>): void; | ||
rm(path: misc.PathLike, a: misc.TCallback<void> | opts.IRmOptions, b?: misc.TCallback<void>): void { | ||
throw new Error('Not implemented'); | ||
} | ||
|
||
fchmod(fd: number, mode: misc.TMode, callback: misc.TCallback<void>): void { | ||
throw new Error('Not implemented'); | ||
} | ||
|
||
chmod(path: misc.PathLike, mode: misc.TMode, callback: misc.TCallback<void>): void { | ||
throw new Error('Not implemented'); | ||
} | ||
|
||
lchmod(path: misc.PathLike, mode: misc.TMode, callback: misc.TCallback<void>): void { | ||
throw new Error('Not implemented'); | ||
} | ||
|
||
fchown(fd: number, uid: number, gid: number, callback: misc.TCallback<void>): void { | ||
throw new Error('Not implemented'); | ||
} | ||
|
||
chown(path: misc.PathLike, uid: number, gid: number, callback: misc.TCallback<void>): void { | ||
throw new Error('Not implemented'); | ||
} | ||
|
||
lchown(path: misc.PathLike, uid: number, gid: number, callback: misc.TCallback<void>): void { | ||
throw new Error('Not implemented'); | ||
} | ||
|
||
watchFile(path: misc.PathLike, listener: (curr: misc.IStats, prev: misc.IStats) => void): misc.IStatWatcher; | ||
watchFile( | ||
path: misc.PathLike, | ||
options: opts.IWatchFileOptions, | ||
listener: (curr: misc.IStats, prev: misc.IStats) => void, | ||
): misc.IStatWatcher; | ||
watchFile(path: misc.PathLike, a, b?): misc.IStatWatcher { | ||
throw new Error('Not implemented'); | ||
} | ||
|
||
unwatchFile(path: misc.PathLike, listener?: (curr: misc.IStats, prev: misc.IStats) => void): void { | ||
throw new Error('Not implemented'); | ||
} | ||
|
||
createReadStream(path: misc.PathLike, options?: opts.IReadStreamOptions | string): misc.IReadStream { | ||
throw new Error('Not implemented'); | ||
} | ||
|
||
createWriteStream(path: misc.PathLike, options?: opts.IWriteStreamOptions | string): misc.IWriteStream { | ||
throw new Error('Not implemented'); | ||
} | ||
|
||
watch( | ||
path: misc.PathLike, | ||
options?: opts.IWatchOptions | string, | ||
listener?: (eventType: string, filename: string) => void, | ||
): misc.IFSWatcher { | ||
throw new Error('Not implemented'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const enum FsaToNodeConstants { | ||
Separator = '/', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export type FsLocation = [folder: string[], file: string]; |