Class AsyncMirror

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.Backend.IndexedDB.Create(function(e, idbfs) {
BrowserFS.Backend.InMemory.Create(function(e, inMemory) {
BrowserFS.Backend.AsyncMirror({
sync: inMemory, async: idbfs
}, function(e, mirrored) {
BrowserFS.initialize(mirrored);
});
});
});

Hierarchy

Constructors

Properties

_async: FileSystem
_initializeCallbacks: ((e?) => void)[] = []

Type declaration

    • (e?): void
    • Parameters

      Returns void

_isInitialized: boolean = false
_queue: AsyncOperation[] = []

Queue of pending asynchronous operations.

_queueRunning: boolean = false
_ready: Promise<AsyncMirror> = ...
_sync: FileSystem
Create: any = ...
Name: "AsyncMirror" = 'AsyncMirror'

Accessors

Methods

  • Test whether or not the given path exists by checking with the file system. Then call the callback argument with either true or false.

    Parameters

    • p: string
    • cred: Cred

    Returns Promise<boolean>

  • Asynchronous mkdir.

    Parameters

    • p: string
    • mode: number

      Mode to make the directory using. Can be ignored if the filesystem doesn't support permissions.

    • cred: Cred

    Returns Promise<void>

  • Asynchronous readdir. Reads the contents of a directory.

    The callback gets two arguments (err, files) where files is an array of the names of the files in the directory excluding '.' and '..'.

    Parameters

    • p: string
    • cred: Cred

    Returns Promise<string[]>

  • Asynchronous realpath. The callback gets two arguments (err, resolvedPath).

    Note that the Node API will resolve path to an absolute path.

    Parameters

    • p: string
    • cred: Cred

    Returns Promise<string>

  • Asynchronous rename. No arguments other than a possible exception are given to the completion callback.

    Parameters

    • oldPath: string
    • newPath: string
    • cred: Cred

    Returns Promise<void>

  • Asynchronous symlink.

    Parameters

    • srcpath: string
    • dstpath: string
    • type: string

      can be either 'dir' or 'file'

    • cred: Cred

    Returns Promise<void>

  • Change file timestamps of the file referenced by the supplied path.

    Parameters

    • p: string
    • atime: Date
    • mtime: Date
    • cred: Cred

    Returns Promise<void>

  • Asynchronously writes data to a file, replacing the file if it already exists.

    The encoding option is ignored if data is a buffer.

    Parameters

    • fname: string
    • data: Uint8Array
    • flag: FileFlag
    • mode: number
    • cred: Cred

    Returns Promise<void>

  • Synchronously writes data to a file, replacing the file if it already exists.

    The encoding option is ignored if data is a buffer.

    Parameters

    • fname: string
    • data: Uint8Array
    • flag: FileFlag
    • mode: number
    • cred: Cred

    Returns void

Generated using TypeDoc