Line

packages/engine/transactionalWriter

Ticket 7.1 -- in-memory transactional file compiler.

Engine, v0.9. Source: packages/engine/transactionalWriter.mjs.

Functions#

createTransaction()#

createTransaction(root): object

Defined in: packages/engine/transactionalWriter.mjs:49

Create a new transaction against root. Nothing under root is touched until (and unless) commit() succeeds.

Parameters#

root

any

Returns#

root

root: any

commit()

commit(opts?): object

Validate the buffered result in an isolated shadow copy of root, then either:

  • commit: replay every staged write onto the real root (via packages/core/fs.mjs's write()) and clear the buffer, or
  • abort: leave root completely untouched. Either way the shadow copy itself is always cleaned up.
Parameters
opts?

validate defaults to the same aggregateValidation(DEFAULT_ENFORCERS) set construct validate runs; overridable for tests and for a caller that wants a narrower or different check.

validate?

(shadowRoot) => object = ...

Returns

object

committed

committed: boolean

violations

violations: any[]

pendingFiles()

pendingFiles(): any[]

Root-relative paths of every file currently staged in this transaction.

Returns

any[]

readFile()

readFile(relPath): any

Read back a staged write, or fall through to the real file on disk if nothing has been staged for that path yet. Returns undefined if neither exists.

Parameters
relPath

any

Returns

any

reset()

reset(): void

Discard every staged write without touching disk.

Returns

void

writeFile()

writeFile(relPath, content): void

Stage a file write; content replaces any earlier staged write for the same path in this same transaction. relPath may be absolute (under root) or already root-relative; either way it's stored root-relative with posix separators.

Parameters
relPath

any

content

any

Returns

void