import { Word, emptyWord } from "./word" export interface Memory { value: () => Word set: (word: Word) => void } export function memory(initialValue: Word): Memory export function memory(width: Width): Memory export function memory(valueOrWidth: Width | Word): Memory { let word = typeof valueOrWidth === 'number' ? emptyWord(valueOrWidth) : valueOrWidth function set(newWord: Word) { word = newWord } function value() { return word } return { value, set } }