noggin

Memory provider

The memory provider keeps a noggin entirely in process. Nothing is persisted; the noggin dies with the process (or sooner, when you call dispose()). It's the canonical backend for tests, demos, and short-lived scratch noggins.

At a glance

Schemememory://
Module@noggin/engine/providers/memory
PersistentNo — process lifetime only
Read-onlyNo
Cross-processNone — each process has its own copy
Runs inNode, browsers, Deno — anywhere the engine runs

When to use

Use this for:

If you want anything to survive a reload, switch to file:// or localstorage://.

Quick start

import { openMemoryNoggin } from '@noggin/engine/providers/memory';

const noggin = await openMemoryNoggin({ label: 'demo' });
await noggin.push({ title: 'just trying things' });
await noggin.dispose();

Or via the registry:

import { openNoggin } from '@noggin/engine';
import '@noggin/engine/providers/memory';

const noggin = await openNoggin('memory://demo');

URL syntax

memory://<label>. The label is purely decorative — it shows up in describe() and noggin.location so multiple memory noggins are easy to tell apart in logs. There is no shared registry of labels; two calls to openMemoryNoggin({ label: 'demo' }) return two independent noggins.

Options

openMemoryNoggin(opts) accepts:

OptionDefaultPurpose
label'in-memory'Human-readable tag shown in describe()
initialDocumentnullSeed the noggin with an existing NogginDocument
import { openMemoryNoggin } from '@noggin/engine/providers/memory';

const noggin = await openMemoryNoggin({
  label: 'seeded',
  initialDocument: {
    schemaVersion: 1,
    active: null,
    items: [
      { key: 'k1', parentKey: null, title: 'pre-loaded', done: false, notes: [] },
    ],
  },
});

The initial document is normalized + validated — it has to be a shape the engine would otherwise accept on disk.

Behaviour

Error codes you might see

CodeWhen
disposedapply() after dispose()
invalid-documentinitialDocument failed structural validation

Performance

The memory provider is the floor for engine performance. The golden test suite issues thousands of verbs per test run against memory noggins. If a verb is slow in this provider, the bottleneck is in the engine itself, not in I/O.