vfs-frontend icon indicating copy to clipboard operation
vfs-frontend copied to clipboard

๐ŸŒˆ๐Ÿ‘This is vfs for pure front end๐ŸŽ๐ŸŒˆ

vfs-frontend

VFS-frontend is a simple virtual file system implemented purely on the frontend, where a virtual file system is built by simply passing blob binary data with a zip attribute๏ผŒThe JSZip library is used for parsing blob data

English | ็ฎ€ไฝ“ไธญๆ–‡

demo

https://ricbet.github.io/vfs-frontend/

install

yarn add vfs-frontend

how to use

const vfsService = new ZipVFSService();

vfsService.mount(blob).then(async () => {
    // do it
});

Now, vfsService has been mounted, for example

mount

The root directory defaults to '/', you can use the 'ls' method to view all files in a directory๏ผŒ for example

vfsService.ls('/').then((data: Inode[]) => {
    // do it
})
ls

๐ŸŒˆenjoy๐Ÿ˜Š๐ŸŒˆ

api

interface IVfsable<T> {
    mount(
        data: T,
        options?: {
            name: string;
        }
    ): Promise<never>;

    ls(path: string): Promise<Inode[]>;

    read(path: string, encode?: string): Promise<string | Error>;

    mkdir(path: string): Promise<Inode | Error>;

    touch(path: string): Promise<Inode | Error>;

    write(path: string, options: { isAppend: boolean }, content: string): Promise<never | Error>;

    exist(path: string): Promise<boolean>;

    cp(source: string, copyend: string): Promise<never | Error>;

    mv(source: string, target: string): Promise<never | Error>;

    rm(path: string, options: { isForce: boolean; isRecursive: boolean }): Promise<never | Error>;

    isMount: () => boolean;

    getBlob: () => Promise<Blob>;
}

license

MIT