GizStackGizStack
View .mdOpen in ChatGPTOpen in Claude

gizlang/kept

the machine's derived data, each kept by the hash of what it is made of, so a program's next start reads it back instead of making it again (a game's textures in their blocks, a rig's centers of rotation). An entry is bytes; its maker encodes it. A host with no file system (a page) keeps nothing and makes each every time.

gizlang
import * as Kept from "gizlang/kept";

Functions

folder

gizlang
function folder(kind: string): string

The folder of KIND's entries in the machine's cache, "" when there is none.

Effects: fail, io, alloc.

keyOf

gizlang
function keyOf(source: bytes, version: string, options: string = ""): string

The key of an entry made of SOURCE by the maker's VERSION and its OPTIONS: a new version makes every entry again.

Effects: fail, alloc.

read

gizlang
function read(folder: string, key: string): bytes | undefined

The entry KEY in FOLDER, or none.

Effects: fail, io, alloc.

write

gizlang
function write(folder: string, key: string, data: bytes): void

Keeps DATA as entry KEY in FOLDER, replacing the file there in one step. It is not synced: a crash that cuts the file short leaves a corrupt entry, which its reader refuses and makes again. A write that fails keeps no entry.

Effects: fail, read, write, console, io, alloc.