# bun-repl

> Experimental REPL for Bun

Latest version **2.1.1** (published 2023-09-28) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install bun-repl
pnpm add bun-repl
yarn add bun-repl
bun add bun-repl
```

Provides the command `bun-repl`.

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 2.1.1 |
| Published | 2023-09-28 |
| First published | 2022-08-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 284.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 81 |
| Author | jhmaster |
| Maintainers | jhmaster |
| Keywords | bun, repl, cli, ts, js |

## Links

- npm: https://www.npmjs.com/package/bun-repl
- Repository: https://github.com/jhmaster2000/bun-repl
- Homepage: https://github.com/jhmaster2000/bun-repl#readme
- Issues: https://github.com/jhmaster2000/bun-repl/issues
- npm.io page: https://npm.io/package/bun-repl

## Dependencies (1)

- [@swc/core](https://npm.io/package/@swc/core.md) ^1.3.90

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 2.1.1 (latest) — 2023-09-28
- 2.1.0 — 2023-09-28
- 2.0.9 — 2023-09-28
- 2.0.8 — 2023-09-18
- 2.0.7 — 2023-09-15
- 2.0.6 — 2023-09-14
- 2.0.5 — 2023-09-11
- 2.0.4 — 2023-09-10
- 2.0.3 — 2023-09-10
- 2.0.2 — 2023-09-09
- 2.0.1 — 2023-09-08
- 2.0.0 — 2023-09-08
- 1.4.0 — 2023-07-12
- 1.3.3 — 2023-01-31
- 1.3.2 — 2023-01-31
- … 15 more at https://npm.io/package/bun-repl/versions

## README

# bun-repl [![GitHub version][github-image]][github-url] [![GitHub code size in bytes][size-image]][github-url] [![license][license-image]][license-url]

Experimental REPL for [Bun](https://github.com/oven-sh/bun)

## Install
You can use it directly via Bun with:
```sh
bun repl
```
No installation required!

### Versioning
[npm](https://www.npmjs.com/package/bun-repl) and [GitHub](https://github.com/jhmaster2000/bun-repl/releases) releases will always be guaranteed to not rely on current Bun canary versions, but support for any version other than the latest non-canary will not be guaranteed.

The source code repository latest commit may contain code not yet in any release which depends on currently Bun canary-only features and has no guarantees.

## Features

* Seamless JavaScript & TypeScript execution
* Single run CLI flags `--eval` and `--print`
* Top level import syntax supported (`import fs from 'fs'`)
* Top level await (experimental)
* Lazy-loaded builtin modules as preloaded global variables. (including Bun modules! Try `ffi` or `sqlite`)
* Import either CommonJS or ESM local files and packages into the REPL
* Node.js REPL special underscore variables provided (`_` and `_error`)
* Resistent to global object modification (output quality may decrease but never crash)
* Node.js `repl` module polyfill
* Persistent execution history (`↑` `↓`)
* REPL Commands (`.command`)

## Usage
```sh
bun repl [options]
```
Pass the `-h` or `--help` CLI option for a list of all options.

Type `.help` within the REPL for a list of commands.

Press `↑` and `↓` to travel up or down the execution history.

### The `repl` module polyfill
`bun repl` exposes a special variable `repl` which provides access to a REPL interface like the Node.js REPL (also accessible through import/require of `repl` or `node:repl`).

Currently only a subset of the `node:repl` API is implemented, see below:
* `repl` global object ✅
    * `start()` function ❌
    * `writer()` function ✅ (Partial)
        * `options` object ✅
    * `repl` property ❌
    * `builtinModules` array ✅
    * `REPL_MODE_SLOPPY` symbol ✅
    * `REPL_MODE_STRICT` symbol ✅
    * `REPLServer` class ❌
    * `Recoverable` class ❌

You can use `repl.writer.options` like you would in Node.js REPL to customize the live output of the running REPL.

## Known issues & limitations
PRs are welcome to help fix any of the items below or anything else.

* Top level await is only *partially* supported. Needs improvement.
* Multi-line inputs are not supported.

[github-url]:https://github.com/jhmaster2000/bun-repl
[github-image]:https://img.shields.io/github/package-json/v/jhmaster2000/bun-repl.svg?color=gray
[license-url]:https://github.com/jhmaster2000/bun-repl/blob/master/LICENSE.md
[license-image]:https://img.shields.io/npm/l/bun-repl.svg
[size-image]:https://img.shields.io/github/languages/code-size/jhmaster2000/bun-repl.svg

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