Skip to content

MemoryFileProvider

Defined in: file-provider/memory.ts:28

In-memory file provider

const provider = new MemoryFileProvider({
'/spec/index.md': '# Main\n:::include ./intro.md :::',
'/spec/intro.md': '## Introduction\nContent here...'
});
const content = await provider.readText('/spec/index.md');
const resolved = provider.resolve('/spec/index.md', './intro.md');
// resolved === '/spec/intro.md'

new MemoryFileProvider(files): MemoryFileProvider

Defined in: file-provider/memory.ts:31

Record<string, string> = {}

MemoryFileProvider

canonicalize(path): string

Defined in: file-provider/memory.ts:92

Convert a path to its canonical form

Canonical paths are:

  • Absolute (no relative segments)
  • Normalized (no . or .. segments)
  • Consistent across platform (forward slashes for web/memory)

string

Path to canonicalize

string

Canonical path

FileProvider.canonicalize


deleteFile(path): boolean

Defined in: file-provider/memory.ts:48

Remove a file from memory

string

boolean


hasFile(path): boolean

Defined in: file-provider/memory.ts:55

Check if a file exists

string

boolean


listFiles(): string[]

Defined in: file-provider/memory.ts:62

Get all file paths

string[]


readText(path): Promise<string>

Defined in: file-provider/memory.ts:66

Read file contents as UTF-8 text

string

Canonical file path

Promise<string>

File contents as string

FileNotFoundError if file doesn’t exist

FileReadError if file cannot be read

FileProvider.readText


resolve(fromFile, relativePath): string

Defined in: file-provider/memory.ts:77

Resolve a relative path from a source file’s location

string

Canonical path of the file containing the reference

string

Relative path to resolve (e.g., ”./foo.md”, ”../bar.md”)

string

Canonical resolved path

FileProvider.resolve


setFile(path, content): void

Defined in: file-provider/memory.ts:41

Add or update a file in memory

string

string

void