# brl

> readline wrapper that supports background logging

Latest version **0.0.2** (published 2019-05-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install brl
pnpm add brl
yarn add brl
bun add brl
```

## 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.0.2 |
| Published | 2019-05-17 |
| First published | 2019-05-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 11 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Edgar ONGHENA |
| Maintainers | edgarogh |
| Keywords | rl, readline, log |

## Links

- npm: https://www.npmjs.com/package/brl
- npm.io page: https://npm.io/package/brl

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 0.0.2 (latest) — 2019-05-17
- 0.0.1 — 2019-05-17

## README

# [**brl**](https://www.npmjs.com/package/brl)
_Background-log-supporting ReadLine_

[![GitHub license](https://img.shields.io/github/license/edgarogh/brl.svg)](https://github.com/edgarogh/brl/blob/master/LICENSE)
[![David](https://img.shields.io/david/edgarogh/brl.svg)](https://www.npmjs.com/package/brl)

> Have you ever tried using the node `readline` module while having an async callback logging stuff in the background? This breaks the whole `readline` prompt.
>
> `brl` is a `readline` wrapper that uses weird terminal escape tricks, and intercepts `process.stdout`, in order to move the prompt down every time a line is logged.

## Installation
`npm install brl`

## Usage
```typescript
import { createInterface, BRLInterface } from 'brl';
```

The library can be used in two different ways:
 * `createInterface` has the same API as `readline` but is a bit limited
 * `BRLInterface` is quite easy to use and gives you a bit more control over some features

### Examples
```typescript
import { createInterface } from 'brl';

// Same API as readline (actually, it returns a real readline interface)
const rl = createInterface();
rl.setPrompt('> ');
rl.on('line', line => rl.prompt());
rl.prompt();

// Simulate background log
setInterval(() => console.log('Background log...'), 1000);
```

```typescript
import { BRLInterface } from 'brl';

const iface = new BRLInterface();
iface.setPrompt('> ');
iface.promptLoop(); // You can pass a callback directly to this method
// iface.prompt();
// iface.onLine([cb]);
// iface.start()       !!! If you don't use promptLoop(), you must explicitly start the interface

// iface.readline      !!! Access to the underlying readline interface

// Simulate background log
setInterval(() => console.log('Background log...'), 1000);
```

## Bugs & Suggestions
If you notice any bug or have a suggestion, please tell me about it in the issues, it will help everyone!

## License
**brl** is licensed under the very permissive [MIT License](https://tldrlegal.com/license/mit-license). You may use it for commercial projects if you comply to the license. However, the core feature's code was written by [Eric](https://stackoverflow.com/users/102441/eric) in a [StackOverflow answer](https://stackoverflow.com/a/10608048/5554145) licensed as CC-BY-SA. Thanks to him for his big indirect contribution !

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