# arepl-backend

> JS interface to python evaluator for AREPL

Latest version **4.0.0** (published 2025-08-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install arepl-backend
pnpm add arepl-backend
yarn add arepl-backend
bun add arepl-backend
```

## Health

**Score 40/100 (D)** — status: stable.

Positive: no vulnerabilities; high maintenance score.

Warnings: low downloads; no types; no esm support.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2025-08-17 |
| First published | 2017-12-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 272.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 14 |
| Author | Almenon |
| Maintainers | almenon |
| Keywords | IDE, python, real-time, AREPL |

## Links

- npm: https://www.npmjs.com/package/arepl-backend
- Repository: https://github.com/Almenon/arepl-backend
- Homepage: https://github.com/Almenon/arepl-backend#readme
- Issues: https://github.com/Almenon/arepl-backend
- npm.io page: https://npm.io/package/arepl-backend

## Dependencies (1)

- [python-shell](https://npm.io/package/python-shell.md) ^5.0.0

## Alternatives

- [adhdev](https://npm.io/package/adhdev.md) — 11.1K weekly downloads
- [react-slide-button](https://npm.io/package/react-slide-button.md) — 310 weekly downloads
- [better](https://npm.io/package/better.md) — 42 weekly downloads
- [react-native-swipe-image](https://npm.io/package/react-native-swipe-image.md) — 22 weekly downloads
- [nl.fokkezb.pulltorefresh](https://npm.io/package/nl.fokkezb.pulltorefresh.md) — 11 weekly downloads

## Recent versions

- 4.0.0 (latest) — 2025-08-17
- 3.0.5 — 2024-11-18
- 3.0.4 — 2024-11-17
- 3.0.3 — 2024-11-15
- 3.0.2 — 2024-11-15
- 3.0.1 — 2024-11-15
- 3.0.0 — 2024-11-14
- 2.1.0 — 2023-03-06
- 2.0.2 — 2022-10-23
- 2.0.1 — 2021-05-11
- 1.3.15 — 2021-03-27
- 1.3.14 — 2020-11-21
- 1.3.13 — 2020-11-21
- 2.0.3 — 2020-11-20
- 1.3.12 — 2020-11-01
- … 56 more at https://npm.io/package/arepl-backend/versions

## README

# AREPL-backend [![npm version](https://badge.fury.io/js/arepl-backend.svg)](https://badge.fury.io/js/arepl-backend) ![example workflow](https://github.com/almenon/AREPL-backend/actions/workflows/tests.yml/badge.svg)

JS interface to python evaluator for AREPL.

Evaluates python code and sends back the user variables and/or any errors.

Although it is meant for AREPL, it is not dependent upon AREPL and can be used by any project.

**Important Note**: this should ONLY be used to execute trusted code.  It does not have any security features whatsoever.

## Installation

> npm install [arepl-backend](https://www.npmjs.com/package/arepl-backend)

Must have python 3.8 or greater

## Usage

see <https://github.com/Almenon/AREPL-vscode> for example useage.

## For developers:

Semantic release cheatsheet:

    | Commit message       | Release type |
    |----------------------|--------------|
    | fix: msg             | patch        |
    | feat: msg            | feature      |
    | perf: msg            |              |
    | BREAKING CHANGE: msg | breaking     |

## API

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

#### Table of Contents

*   [PythonState](#pythonstate)
*   [constructor](#constructor)
    *   [Parameters](#parameters)
*   [execCode](#execcode)
    *   [Parameters](#parameters-1)
*   [sendStdin](#sendstdin)
    *   [Parameters](#parameters-2)
*   [restart](#restart)
    *   [Parameters](#parameters-3)
*   [stop](#stop)
    *   [Parameters](#parameters-4)
*   [start](#start)
    *   [Parameters](#parameters-5)
*   [onResult](#onresult)
    *   [Parameters](#parameters-6)
*   [onPrint](#onprint)
    *   [Parameters](#parameters-7)
*   [onStderr](#onstderr)
    *   [Parameters](#parameters-8)
*   [handleResult](#handleresult)
    *   [Parameters](#parameters-9)
*   [checkSyntax](#checksyntax)
    *   [Parameters](#parameters-10)
*   [formatPythonException](#formatpythonexception)
    *   [Parameters](#parameters-11)
    *   [Examples](#examples)

### PythonState

Starting = Starting or restarting.
Ending = Process is exiting.
Executing = Executing inputted code.
DirtyFree = evaluator may have been polluted by side-effects from previous code, but is free for more code.
FreshFree = evaluator is ready for the first run of code

### constructor

starts python\_evaluator.py

#### Parameters

*   `options`  Process / Python options. If not specified sensible defaults are inferred. (optional, default `{}`)

### execCode

does not do anything if program is currently executing code

#### Parameters

*   `code` &#x20;

### sendStdin

#### Parameters

*   `message` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**&#x20;

### restart

kills python process and restarts.  Force-kills if necessary after 50ms.
After process restarts the callback passed in is invoked

#### Parameters

*   `callback`   (optional, default `()=>{}`)

### stop

Kills python process.  Force-kills if necessary after 50ms.
You can check python\_evaluator.running to see if process is dead yet

#### Parameters

*   `kill_immediately`   (optional, default `false`)

### start

starts python\_evaluator.py. Will NOT WORK with python 2

#### Parameters

*   `finishedStartingCallback` &#x20;

### onResult

Overwrite this with your own handler.
is called when program fails or completes

#### Parameters

*   `foo` &#x20;

### onPrint

Overwrite this with your own handler.
Is called when program prints

#### Parameters

*   `foo` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**&#x20;

### onStderr

Overwrite this with your own handler.
Is called when program logs stderr

#### Parameters

*   `foo` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**&#x20;

### handleResult

handles pyshell results and calls onResult / onPrint

#### Parameters

*   `results` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**&#x20;

### checkSyntax

checks syntax without executing code

#### Parameters

*   `code` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**&#x20;

Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)** rejects w/ stderr if syntax failure

### formatPythonException

gets rid of unnecessary File "<string>" message in exception

#### Parameters

*   `err` &#x20;

#### Examples

```javascript
err:
Traceback (most recent call last):\n  File "<string>", line 1, in <module>\nNameError: name \'x\' is not defined\n
```

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