Skip to content

MemoryVolume

Nodepod API


Nodepod API / src / MemoryVolume

Defined in: src/memory-volume.ts:484

new MemoryVolume(handler?, lazyResidentMaxBytes?): MemoryVolume

Defined in: src/memory-volume.ts:724

MemoryHandler | null

number = ...

MemoryVolume

get contentPackingEnabled(): boolean

Defined in: src/memory-volume.ts:1681

boolean


get evictionEnabled(): boolean

Defined in: src/memory-volume.ts:2073

boolean

access(p, modeOrCb?, cb?): void

Defined in: src/memory-volume.ts:3734

string

number | ((err) => void)

(err) => void

void


accessSync(p, mode?): void

Defined in: src/memory-volume.ts:3339

string

number = 0

void


adoptPackContent(pack, manifest, buffer, keepResident): number

Defined in: src/memory-volume.ts:2096

Turn files that were mounted from buffer (a pack’s data) into paged-out stubs backed by pack, so the buffer can be collected. Files for which keepResident is true are copied out of it instead. Anything written since the mount no longer points into buffer and is left alone.

number

readonly BinaryVolumeEntry[]

ArrayBufferLike

(path) => boolean

number


appendFileSync(p, data): void

Defined in: src/memory-volume.ts:3628

string

unknown

void


childKindsSync(dirPath, names): ("file" | "directory" | "symlink" | null)[]

Defined in: src/memory-volume.ts:2822

For each name in a directory: what lstatSync(dir/name) would say it is, from one lookup of the directory (readdir withFileTypes asks this for every entry). null where the entry isn’t a child of the directory right now; lstat decides those.

string

string[]

("file" | "directory" | "symlink" | null)[]


chmodSync(_p, _mode): void

Defined in: src/memory-volume.ts:3503

string

number

void


chownSync(p, uid, gid): void

Defined in: src/memory-volume.ts:3537

string

number

number

void


copyFileSync(src, dest, mode?): void

Defined in: src/memory-volume.ts:3350

string

string

number = 0

void


createReadStream(p): object

Defined in: src/memory-volume.ts:3868

string

object

on: (event, cb) => void

string

(…args) => void

void

pipe: (dest) => unknown

unknown

unknown


createWriteStream(p): object

Defined in: src/memory-volume.ts:3897

string

object

end: (data?) => void

string | Uint8Array<ArrayBufferLike>

void

on: (event, cb) => void

string

(…args) => void

void

write: (data) => boolean

string | Uint8Array<ArrayBufferLike>

boolean


dispose(): void

Defined in: src/memory-volume.ts:953

Clean up all owned data and listeners. A disposed volume is empty.

void


enableContentPacking(opts?): void

Defined in: src/memory-volume.ts:1627

Keep node_modules files that nobody reads deflated in memory (see PackedChunk). Main thread only: rounds run after the volume has been quiet for a while and yield between slices; reads stay synchronous.

(bytes) => Promise<Uint8Array<ArrayBufferLike>>

void


enableEviction(source, budgetBytes): void

Defined in: src/memory-volume.ts:2067

Let content mounted with a src (package packs) be dropped from memory under an LRU budget and read back from source on demand. Paged-out files can’t be read synchronously: callers await ensureResident() first.

VolumeContentSource

number

void


ensureResident(paths): Promise<void>

Defined in: src/memory-volume.ts:2186

Page the given files (and their pack neighbours) back into memory.

string | readonly string[]

Promise<void>


existsSync(p): boolean

Defined in: src/memory-volume.ts:2807

string

boolean


getStats(): object

Defined in: src/memory-volume.ts:890

object

dirCount: number

fileCount: number

lazyResidentBytes: number

packedBytes: number

packedFiles: number

packedStoredBytes: number

pagedOutBytes: number

pagedOutFiles: number

pagedOutSyncMisses: number

residentPackBytes: number

totalBytes: number

watcherCount: number


holdContentPacking(): () => void

Defined in: src/memory-volume.ts:1712

Keep packing rounds from packing anything until the returned release is called (a bulk copy of the packages is about to be taken: packing them first would only have it inflate them again).

() => void


inspectNode(p): VolumeNodeInfo | null

Defined in: src/memory-volume.ts:790

lstat-like view of the node at exactly p: no symlink is followed, not even in a parent directory (null for paths that only exist through one). Never hydrates lazy content and never throws. inode is an opaque identity token shared by hardlinks and stable across renames.

string

VolumeNodeInfo | null


isPagedOut(p): boolean

Defined in: src/memory-volume.ts:2175

true when reading p synchronously would need ensureResident() first.

string

boolean


kindSync(p): "file" | "directory" | null

Defined in: src/memory-volume.ts:2840

Whether statSync(p).isFile() would be true (‘file’), false (‘directory’), or statSync would throw ENOENT (null): existsSync plus the kind, without building a stat.

string

"file" | "directory" | null


lchmodSync(p, mode): void

Defined in: src/memory-volume.ts:3520

string

number

void


lchownSync(p, uid, gid): void

Defined in: src/memory-volume.ts:3555

string

number

number

void


linkCount(p): number

Defined in: src/memory-volume.ts:2127

How many paths link to the file at p (1 for anything that isn’t a hardlinked file).

string

number


linksOf(p): string[]

Defined in: src/memory-volume.ts:2138

Every path that is a hardlink to the file at p (including p), without following symlinks.

string

string[]


linkSync(existingPath, newPath): void

Defined in: src/memory-volume.ts:3431

string

string

void


lstat(p, cb?): void

Defined in: src/memory-volume.ts:3702

string

(err, stats?) => void

void


lstatSync(p): FileStat

Defined in: src/memory-volume.ts:2909

string

FileStat


lutimesSync(p, atime, mtime): void

Defined in: src/memory-volume.ts:3610

string

number | Date

number | Date

void


markLazyInvalidated(p): void

Defined in: src/memory-volume.ts:2556

string

void


mkdirSync(p, options?): string | undefined

Defined in: src/memory-volume.ts:3043

string

number

boolean

string | undefined


mountBinarySnapshot(snapshot, notifyBulk?): number

Defined in: src/memory-volume.ts:1077

ArrayBuffer

BinaryVolumeEntry[]

boolean = true

number


mountEntries(entries, opts?): number

Defined in: src/memory-volume.ts:1192

Merge entries into the volume. Missing parents are created and an entry whose path holds a node of another kind replaces it. With notify, every entry fires the same watcher/global/mutation events a regular write would. Without it, a single mount mutation is reported for the whole batch and the new entries fire no watchers (removing a node of another kind at an entry’s path still does, like any removal).

readonly MountEntry[]

boolean

number


off(event, handler): this

Defined in: src/memory-volume.ts:746

"change"

FileChangeHandler

this

off(event, handler): this

Defined in: src/memory-volume.ts:747

"delete"

FileDeleteHandler

this


on(event, handler): this

Defined in: src/memory-volume.ts:736

"change"

FileChangeHandler

this

on(event, handler): this

Defined in: src/memory-volume.ts:737

"delete"

FileDeleteHandler

this


onGlobalChange(cb): () => void

Defined in: src/memory-volume.ts:3855

(path, event) => void

() => void


onMetaChange(cb): () => void

Defined in: src/memory-volume.ts:763

Subscribe to metadata changes only (chmod/chown/utimes and their l* variants), with the fields that changed. Cheaper than onMutation, which resolves canonical paths for every mutation. Returns an unsubscribe fn.

(path, change) => void

() => void


onMutation(cb): () => void

Defined in: src/memory-volume.ts:779

(mutation) => void

() => void


onNotificationBurst(cb): () => void

Defined in: src/memory-volume.ts:3317

(start) => void

() => void


onSilentMount(cb): () => void

Defined in: src/memory-volume.ts:774

Entries mounted without notify (bulk restores) fire no watchers: cb gets their paths, so processes that listed those directories earlier can look again. Cheaper than onMutation, which journals every change.

(paths) => void

() => void


openFileHandleSync(p): VolumeFileHandle

Defined in: src/memory-volume.ts:2986

string

VolumeFileHandle


packContentNow(): Promise<void>

Defined in: src/memory-volume.ts:1725

Run a packing round now (tests; normally rounds start on their own).

Promise<void>


pagedOutPaths(root): string[]

Defined in: src/memory-volume.ts:2152

Paged-out files at or below root (canonical paths, symlinks not followed).

string

string[]


pauseEviction(): () => void

Defined in: src/memory-volume.ts:2078

Hold off eviction (e.g. during an install that reads packages synchronously). Returns the resume fn.

() => void


peekFileSync(p): Uint8Array

Defined in: src/memory-volume.ts:1690

A file’s bytes for bulk copies (snapshots): like readFileSync, but the file isn’t counted as in use, and a packed file is inflated for the caller and stays packed.

string

Uint8Array


readdir(p, optionsOrCb?, cb?): void

Defined in: src/memory-volume.ts:3711

string

{ withFileTypes?: boolean; } | ((err, files?) => void)

(err, files?) => void

void


readdirSync(p): string[]

Defined in: src/memory-volume.ts:3081

string

string[]


readFile(p, optionsOrCb?, cb?): void

Defined in: src/memory-volume.ts:3676

string

{ encoding?: string; } | ((err, data?) => void)

(err, data?) => void

void


readFileSync(p): Uint8Array

Defined in: src/memory-volume.ts:2956

string

Uint8Array

readFileSync(p, encoding): string

Defined in: src/memory-volume.ts:2957

string

"utf8" | "utf-8"

string


readlinkSync(p): string

Defined in: src/memory-volume.ts:3416

string

string


realpath(p, cb?): void

Defined in: src/memory-volume.ts:3725

string

(err, resolved?) => void

void


realpathSync(p): string

Defined in: src/memory-volume.ts:3359

string

string


rebuildIndexes(): void

Defined in: src/memory-volume.ts:853

Rebuild internal inode indexes after an external tree replacement.

void


relistLazy(dirs): void

Defined in: src/memory-volume.ts:2546

The main thread mounted entries in these directories without per-file notifications: forget their listings (and every cached miss) so the next lookup lists them again and finds the new entries.

string[]

void


removeTreeSync(p): void

Defined in: src/memory-volume.ts:3144

string

void


renameSync(from, to): void

Defined in: src/memory-volume.ts:3194

string

string

void


rmdirSync(p): void

Defined in: src/memory-volume.ts:3116

string

void


setBulkMountHandler(handler): void

Defined in: src/memory-volume.ts:754

((snapshot) => void) | null

void


setMissHandler(handler, lazyDirNames?): void

Defined in: src/memory-volume.ts:2421

VolumeMissHandler | null

string[] = []

void


stat(p, cb?): void

Defined in: src/memory-volume.ts:3693

string

(err, stats?) => void

void


statSync(p): FileStat

Defined in: src/memory-volume.ts:2850

string

FileStat


symlinkSync(target, linkPath, type?): void

Defined in: src/memory-volume.ts:3389

string

string

string

void


toSnapshot(excludePrefixes?, excludeDirNames?): VolumeSnapshot

Defined in: src/memory-volume.ts:995

string[]

Set<string>

VolumeSnapshot


truncateSync(p, len?): void

Defined in: src/memory-volume.ts:3645

string

number = 0

void


unlinkSync(p): void

Defined in: src/memory-volume.ts:3093

string

void


utimesSync(p, atime, mtime): void

Defined in: src/memory-volume.ts:3592

string

number | Date

number | Date

void


watch(target, optionsOrCb?, cb?): FileWatchHandle

Defined in: src/memory-volume.ts:3747

string

WatchCallback | { encoding?: string; persistent?: boolean; recursive?: boolean; }

WatchCallback

FileWatchHandle


writeCacheSync(p, data): void

Defined in: src/memory-volume.ts:3038

string

unknown

void


writeFileSync(p, data): void

Defined in: src/memory-volume.ts:3032

string

unknown

void


static fromBinarySnapshot(snapshot): MemoryVolume

Defined in: src/memory-volume.ts:1070

ArrayBuffer

BinaryVolumeEntry[]

MemoryVolume


static fromSnapshot(snapshot): MemoryVolume

Defined in: src/memory-volume.ts:1137

VolumeSnapshot

MemoryVolume


static snapshotToMountEntries(snapshot): MountEntry[]

Defined in: src/memory-volume.ts:1143

VolumeSnapshot

MountEntry[]