# @wmakeev/vm-sandbox

> JavaScript code sandbox based on node.js vm module

Latest version **0.1.0** (published 2022-01-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install @wmakeev/vm-sandbox
pnpm add @wmakeev/vm-sandbox
yarn add @wmakeev/vm-sandbox
bun add @wmakeev/vm-sandbox
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2022-01-18 |
| First published | 2022-01-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=14 |
| Dependencies | 0 |
| Unpacked size | 4.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Vitaliy V. Makeev |
| Maintainers | wmakeev |
| Keywords | vm, sandbox, metavm, testing, isolation |

## Links

- npm: https://www.npmjs.com/package/@wmakeev/vm-sandbox
- Repository: https://github.com/wmakeev/vm-sandbox
- Homepage: https://github.com/wmakeev/vm-sandbox#readme
- Issues: https://github.com/wmakeev/vm-sandbox/issues
- npm.io page: https://npm.io/package/@wmakeev/vm-sandbox

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads
- [aws-elasticsearch-connector](https://npm.io/package/aws-elasticsearch-connector.md) — 37.4K weekly downloads

## Recent versions

- 0.1.0 (latest) — 2022-01-18

## README

# vm-sandbox

[![npm](https://img.shields.io/npm/v/@wmakeev/vm-sandbox.svg?maxAge=1800&style=flat-square)](https://www.npmjs.com/package/@wmakeev/vm-sandbox)

> JavaScript code sandbox based on node.js `vm` module. Use for better testing and code isolation.

Inspired by [metavm](https://github.com/metarhia/metavm)

## Install

```bash
npm install @wmakeev/vm-sandbox
```

## Using

```js
const src = `
  const { mult, round } = api

  const radius = 12

  const s = round(mult(mult(2, PI), radius))

  s
`

const script = createScript('myScript', src, {
  context: {
    api: {
      mult: (a, b) => a * b,
      round: Math.round
    },
    PI: Math.PI
  }
})

console.log(script.exports) // 75
```

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