Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Memory

A simple namespaced data storage. You can access the memory directly using Memory.memory.

Namespaces

Namespaces aren't just "objects within objects". If you have the namespace a.b.c, a does not contain b and likewise b doesn't contain c.

You can set a to 5 and a.b to 6. a would still be 5.

The only thing affected by namespaces is data removal. If you remove a it will also remove a.b and a.b.c.

Removing a namespace removes all other namespaces that have the removed namespace as a prefix.

The notable exception is Memory.forget with forgetNamespace false (the default). This only removes the specific namespace without affecting anything else.

Hierarchy

Implements

Index

Constructors

constructor

Properties

Protected internalMemory

internalMemory: Namespace

memory

Methods

Protected assignMemory

  • Assign a Namespace to the memory. This does not remove the current memory.

    Calls Object.assign.

    Parameters

    Returns void

forget

  • forget(key: string, forgetNamespace?: undefined | false | true): void
  • Delete the value of the provided namespace key.

    Parameters

    • key: string
    • Optional forgetNamespace: undefined | false | true

      if true this operation behaves like Memory.resetMemory with the key as an argument. Otherwise it merely removes the specified namespace.

    Returns void

remember

  • remember(key: string, value: any): void
  • Store the given value under the namespace key.

    Parameters

    • key: string

      Namespaces are separated by a dot

    • value: any

    Returns void

resetMemory

  • resetMemory(...namespaces: string[]): void
  • Reset the given namespaces and all their children.

    When called with no arguments this flushes the entire memory (i.e. deletes all keys).

    see

    Memory.forget to remove a specific namespace without affecting its children.

    Parameters

    • Rest ...namespaces: string[]

    Returns void

Generated using TypeDoc