MemoryFork class

Forks an existing memory.

Remarks

A memory fork is a memory that is a copy of another memory, but can be modified without affecting the original memory.

Constructors

MemoryFork(Memory)

Creates a new MemoryFork instance.

Methods

deleteValue(string)

Deletes a value from the memory.

getValue<TValue>(string)

Retrieves a value from the memory.

hasValue(string)

Checks if a value exists in the memory.

setValue(string, unknown)

Assigns a value to the memory.

Constructor Details

MemoryFork(Memory)

Creates a new MemoryFork instance.

new MemoryFork(memory: Memory)

Parameters

memory
Memory

Memory to fork.

Method Details

deleteValue(string)

Deletes a value from the memory.

function deleteValue(path: string)

Parameters

path

string

Path to the value to delete in the form of [scope].property. If scope is omitted, the value is deleted from the temporary scope.

Remarks

Only forked values will be deleted.

getValue<TValue>(string)

Retrieves a value from the memory.

function getValue<TValue>(path: string): TValue

Parameters

path

string

Path to the value to retrieve in the form of [scope].property. If scope is omitted, the value is retrieved from the temporary scope.

Returns

TValue

The value or undefined if not found.

Remarks

The forked memory is checked first, then the original memory.

hasValue(string)

Checks if a value exists in the memory.

function hasValue(path: string): boolean

Parameters

path

string

Path to the value to check in the form of [scope].property. If scope is omitted, the value is checked in the temporary scope.

Returns

boolean

True if the value exists, false otherwise.

Remarks

The forked memory is checked first, then the original memory.

setValue(string, unknown)

Assigns a value to the memory.

function setValue(path: string, value: unknown)

Parameters

path

string

Path to the value to assign in the form of [scope].property. If scope is omitted, the value is assigned to the temporary scope.

value

unknown

Value to assign.

Remarks

The value is assigned to the forked memory.