# chez-scheme-js

> Chez Scheme on the web w/ WASM and Workers

Latest version **1.2.0** (published 2025-05-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install chez-scheme-js
pnpm add chez-scheme-js
yarn add chez-scheme-js
bun add chez-scheme-js
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2025-05-03 |
| First published | 2023-02-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 7.2 MB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Trevor Paley |
| Maintainers | theunlocked |

## Links

- npm: https://www.npmjs.com/package/chez-scheme-js
- npm.io page: https://npm.io/package/chez-scheme-js

## Dependencies (2)

- [uuid](https://npm.io/package/uuid.md) ^9.0.0
- [async-mutex](https://npm.io/package/async-mutex.md) ^0.4.0

## Recent versions

- 1.2.0 (latest) — 2025-05-03
- 1.1.0 — 2023-02-11
- 1.0.0 — 2023-02-10

## README

# chez-scheme-js
Chez Scheme on the web

## Browser

`chez-scheme-js` uses `SharedArrayBuffer`, which requires the COOP and COEP security
headers to be set and for there to be a secure context (either localhost or https).

```http
Cross-Origin-Opener-Policy: same-origin
// And one of:
Cross-Origin-Embedder-Policy: require-corp
Cross-Origin-Embedder-Policy: credentialless
```

## Node.js

Node.js is currently unsupported. There is no technical reason it couldn't be,
but figuring out a build system that will support both Node.js and browsers takes some work.
PRs to do this will be accepted.

## Usage

```js
import Scheme from 'chez-scheme-js';

const scheme = new Scheme({
    error: err => console.error(err),
});

console.log(await scheme.init());
// Petite Chez Scheme Version 9.9.9-pre-release.14
// Copyright 1984-2022 Cisco Systems, Inc.
console.log(await scheme.runExpression(`
    (cdr '(1 2 3))

    (define (add-one n) (+ n 1))
    (add-one 2)
`));
// ["(2 3)", "3"]
console.log(await scheme.runExpression('(add-one 5)'));
// ["6"]
```

## Development

Run `npm i` to install dependencies.

This project uses Racket's modified Chez Scheme, which has support for compilation to WASM via Emscripten.
The binaries for it are not checked in, and you will need to compile them yourself.

### Compiling Chez Scheme

You will need `gcc`, `make`, `sh`, and similar programs. If you are using Windows, I recommend using WSL.
You will also need to [install Emscripten](https://emscripten.org/docs/getting_started/downloads.html).

Once you have everything installed, run `npm run build-chez`.
This will generate a custom WebAssembly build of Chez Scheme and copy the relevant artifacts into `src/chez`.

### Building

This project uses Webpack, and it can be compiled with `npm run build` or watched with `npm run watch`.

#### Publishing

First verify the package has all necessary files with `npm pack`. Then run `npm publish` when ready.

### Testing

Currently there are no automated tests. There is a playground in the `demo` directory which can be run with `npm run dev`.

---
_Source: https://npm.io/package/chez-scheme-js · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
