open-index/open-npm huggingface dataset:
npm package: @qp-mongosh/autocomplete
Description: MongoDB Shell Autocomplete Package
Latest version: 0.0.0-dev.27

# `@qp-mongosh/autocomplete`

Package for [MongoDB Shell](mongosh)

## Usage

```js
const autocomplete = require('@qp-mongosh/autocomplete');
const serverVersion = '4.4.0';
const line = 'db.coll.fin';
const completions = autocomplete(serverVersion, line);
if (!completions || !completions.length) {
  return [];
}
const entries = completions[0].map((completion) => {
  return {
    completion
  };
});
```
### API

#### completions = autocomplete(serverVersion, line)
__serverVersion:__ current version of MongoDB
__line:__ current line to autcomplete

Returns an array of completions, and the line we were autocompleting. For
example:

```js
const autocomplete = require('@qp-mongosh/autocomplete');
const serverVersion = '4.4.0';
const line = 'db.coll.re';
const completions = autocomplete(serverVersion, line);
// returns:
// [
//   [ 'db.coll.renameCollection', 'db.coll.replaceOne', 'db.coll.reIndex' ],
//   'db.coll.re' 
// ]
```

Autocomplete is based on currently implemeted APIs in [@qp-mongosh/shell-api](https://www.npmjs.com/package/@qp-mongosh/shell-api)


## Installation
```shell
npm install -S @qp-mongosh/errors
```

[mongosh]: https://github.com/mongodb-js/mongosh
npm package: @qp-mongosh/browser-repl
Description: Browser presentation component for Mongo Shell
Latest version: 0.0.0-dev.10

# Browser Repl

React Browser component for Mongo Shell

## Usage

``` js
import { Shell } from 'mongosh-browser-repl';

export () => {
  return <Shell runtime={runtime} />;
}
```

### Built-in Runtimes

#### IframeRuntime

Uses an iframe window as sandbox for code execution. **NOTE:** the execution is not really sandboxed, the top window is accessible.

``` js
import { IframeRuntime } from 'mongosh-browser-repl';

const runtime = new IframeRuntime(serviceProvider);
```

## API

### `<Shell />`

Shell is a React component with the following properties:

- `runtime: Runtime`: The runtime used to evaluate code.
- `onOutputChanged?: (output: readonly ShellOutputEntry[]) => void`: A function called each time the output changes with an array of `ShellOutputEntryes`.
- `onHistoryChanged?: (history: readonly string[]) => void`: A function called each time the history changes with an array of history entries ordered from the most recent to the oldest entry.
- `redactInfo?: boolean`: If set, the shell will omit or redact entries containing sensitive info from history. Defaults to `false`.
- `maxOutputLength?: number`: The maxiumum number of lines to keep in the output. Defaults to `1000`.
- `maxHistoryLength?: number`: The maxiumum number of lines to keep in the history. Defaults to `1000`.
- `initialOutput?: readonly ShellOutputEntry[]`: An array of entries to be displayed in the output area. Can be used to restore the output between sessions, or to setup a greeting message. **Note**: new entries will not be appended to the array.
- `initialHistory?: readonly string[]`: An array of history entries to prepopulate the history.
  Can be used to restore the history between sessions. Entries must be ordered from the most recent to the oldest. Note: new entries will not be appended to the array.

### `ShellOutputEntry`

An object representing an entry in the shell output, with the following properties:

- `format: 'input' | 'output' | 'error'`: the type of the entry
- `type?: string`: the shell api type if the entry value is a shell api object.
- `value: any`: the value that has to be rendered in output.
npm package: @qp-mongosh/browser-runtime-core
Description: Mongosh browser runtime core
Latest version: 0.0.0-dev.27

# browser-runtime-core

Core and support classes and types used by runtimes.

## Api

### `Runtime`

Encapsulates the details of evaluation logic exposing an implementation
agnostic interface.

All runtimes implement the following interface:

- `evaluate(code: string): Promise<ShellResult>`: Evaluates a string of code.

### `ShellResult`

An object holding the result of an evaluation. Has the following properties:

- `type: string`: the shell api type if the entry value is a shell api object.
- `value: any`: the value that has to be rendered in output.
npm package: @qp-mongosh/browser-runtime-electron
Description: Mongosh browser runtime electron
Latest version: 0.0.0-dev.3

# browser-runtime-electron

## ElectronRuntime

`Runtime` implementation that uses Node.js `vm` module as sandbox for
code execution.

``` js
import { ElectronRuntime } from 'mongosh-browser-repl';

const runtime = new ElectronRuntime(serviceProvider);
```

##### Example: usage in Compass

``` js
import { Shell, ElectronRuntime } from 'mongosh-browser-repl';

const runtime = new ElectronRuntime(
  CompassServiceProvider.fromDataService(dataService)
);

function MyShell(props) {
  return <Shell runtime={runtime} />;
}
```
npm package: @qp-mongosh/js-multiline-to-singleline
Description: Make multiline JS into a single line
Latest version: 0.0.0-dev.27

# `@qp-mongosh/js-multiline-to-singleline`

Package for [MongoDB Shell](https://github.com/mongodb-js/mongosh).

### Installation

```shell
npm install -S @qp-mongosh/js-multiline-to-singleline
```