Options
All
  • Public
  • Public/Protected
  • All
Menu

AsyncMirrorFS mirrors a synchronous filesystem into an asynchronous filesystem by:

  • Performing operations over the in-memory copy, while asynchronously pipelining them to the backing store.
  • During application loading, the contents of the async file system can be reloaded into the synchronous store, if desired.

The two stores will be kept in sync. The most common use-case is to pair a synchronous in-memory filesystem with an asynchronous backing store.

Example: Mirroring an IndexedDB file system to an in memory file system. Now, you can use IndexedDB synchronously.

BrowserFS.configure({
  fs: "AsyncMirror",
  options: {
    sync: { fs: "InMemory" },
    async: { fs: "IndexedDB" }
  }
}, function(e) {
  // BrowserFS is initialized and ready-to-use!
});

Or, alternatively:

BrowserFS.FileSystem.IndexedDB.Create(function(e, idbfs) {
  BrowserFS.FileSystem.InMemory.Create(function(e, inMemory) {
    BrowserFS.FileSystem.AsyncMirror({
      sync: inMemory, async: idbfs
    }, function(e, mirrored) {
      BrowserFS.initialize(mirrored);
    });
  });
});

Hierarchy

Implements

Index

Constructors

constructor

  • Deprecated; use AsyncMirror.Create() method instead.

    Mirrors the synchronous file system into the asynchronous file system.

    IMPORTANT: You must call initialize on the file system before it can be used.

    Parameters

    • sync: FileSystem

      The synchronous file system to mirror the asynchronous file system to.

    • async: FileSystem

      The asynchronous file system to mirror.

    • Default value deprecateMsg: boolean = true

    Returns AsyncMirror

Methods

_syncSync

appendFile

appendFileSync

  • appendFileSync(fname: string, data: any, encoding: string | null, flag: FileFlag, mode: number): void

chmod

chmodSync

  • chmodSync(p: string, isLchmod: boolean, mode: number): void

chown

  • chown(p: string, isLchown: boolean, uid: number, gid: number, cb: BFSOneArgCallback): void

chownSync

  • chownSync(p: string, isLchown: boolean, uid: number, gid: number): void

createFile

createFileSync

  • createFileSync(p: string, flag: FileFlag, mode: number): File

diskSpace

  • diskSpace(p: string, cb: function): void

exists

  • exists(p: string, cb: function): void

existsSync

  • existsSync(p: string): boolean

getName

  • getName(): string

initialize

isReadOnly

  • isReadOnly(): boolean

link

linkSync

  • linkSync(srcpath: string, dstpath: string): void

mkdir

mkdirSync

  • mkdirSync(p: string, mode: number): void

open

openFile

openFileSync

  • openFileSync(p: string, flag: FileFlag, mode: number): File
  • Opens the file at path p with the given flag. The file must exist.

    Parameters

    • p: string

      The path to open.

    • flag: FileFlag

      The flag to use when opening the file.

    • mode: number

    Returns File

    A File object corresponding to the opened file.

openSync

readFile

  • readFile(fname: string, encoding: string | null, flag: FileFlag, cb: BFSCallback<string | Buffer>): void

readFileSync

  • readFileSync(fname: string, encoding: string | null, flag: FileFlag): any

readdir

readdirSync

  • readdirSync(p: string): string[]

readlink

readlinkSync

  • readlinkSync(p: string): string

realpath

  • realpath(p: string, cache: object, cb: BFSCallback<string>): void

realpathSync

  • realpathSync(p: string, cache: object): string

rename

renameSync

  • renameSync(oldPath: string, newPath: string): void

rmdir

rmdirSync

  • rmdirSync(p: string): void

stat

statSync

  • statSync(p: string, isLstat: boolean): Stats

supportsLinks

  • supportsLinks(): boolean

supportsProps

  • supportsProps(): boolean

supportsSynch

  • supportsSynch(): boolean

symlink

  • symlink(srcpath: string, dstpath: string, type: string, cb: BFSOneArgCallback): void

symlinkSync

  • symlinkSync(srcpath: string, dstpath: string, type: string): void

truncate

truncateSync

  • truncateSync(p: string, len: number): void

unlink

unlinkSync

  • unlinkSync(p: string): void

utimes

utimesSync

  • utimesSync(p: string, atime: Date, mtime: Date): void

writeFile

writeFileSync

  • writeFileSync(fname: string, data: any, encoding: string | null, flag: FileFlag, mode: number): void

Static Create

Static isAvailable

  • isAvailable(): boolean

Generated using TypeDoc