Skip to content

Latest commit

 

History

History
32 lines (22 loc) · 900 Bytes

File metadata and controls

32 lines (22 loc) · 900 Bytes

@metta-ts/browser

Browser entry for MeTTa TS. Re-exports everything from @metta-ts/core and adds an in-memory virtual file system so import! works without disk access.

Install

npm install @metta-ts/browser

Usage

import { run } from "@metta-ts/browser";

// A virtual file system: module name -> MeTTa source.
const files = new Map([["math", "(= (double $x) (* 2 $x))"]]);

const results = run(
  `
  !(import! &self math)
  !(double 21)
`,
  files,
);

run(src, files?, fuel?) evaluates a program, resolving import! against the in-memory files. The whole interpreter is pure TypeScript, so it runs in any browser with no native addon and no WASM.

License

MIT.