# readline

> Simple streaming readline module.

Latest version **1.3.0** (published 2015-12-28) · BSD license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.0 |
| Published | 2015-12-28 |
| First published | 2013-07-10 |
| Weekly downloads | 0 |
| License | BSD |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 101 |
| Author | craig brookes |
| Maintainers | craigbrookes |
| Keywords | readline, line by line, file |

## Links

- npm: https://www.npmjs.com/package/readline
- Repository: git@github.com:maleck13/readline
- Homepage: https://github.com/maleck13/readline
- Issues: https://github.com/maleck13/readline/issues
- npm.io page: https://npm.io/package/readline

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 1.3.0 (latest) — 2015-12-28
- 1.2.1 — 2015-11-20
- 1.2.0 — 2015-11-14
- 1.1.0 — 2015-10-03
- 1.0.1 — 2015-09-01
- 1.0.0 — 2015-08-28
- 0.0.8 — 2015-05-23
- 0.0.7 — 2015-01-17
- 0.0.6 — 2015-01-17
- 0.0.5 — 2014-11-04
- 0.0.4 — 2014-10-04
- 0.0.3 — 2013-07-10
- 0.0.2 — 2013-07-10
- 0.0.1 — 2013-07-10

## README

## _readline_
> Read a file line by line.

## Install

## Important. In node 10 there is a core module named readline. Please use linebyline instead, it is the same module just renamed:
[Npm linebyline](https://www.npmjs.com/package/linebyline)

```sh
npm install linebyline
```

## Test
```sh
npm install .
npm test

```


## What's this?

Simple streaming readline module for NodeJS. Reads a file and buffers new lines emitting a _line_ event for each line.

## Usage
### Simple
```js
  var readline = require('linebyline'),
      rl = readline('./somefile.txt');
  rl.on('line', function(line, lineCount, byteCount) {
    // do something with the line of text
  })
  .on('error', function(e) {
    // something went wrong
  });
```

### ASCII file decoding
As the underlying `fs.createReadStream` doesn't care about the specific ASCII encoding of the file, an alternative way to decode the file is by telling the `readline` library to retain buffer and then decoding it using a converter (e.g. [`iconv-lite`](https://www.npmjs.com/package/iconv-lite)).
```js
  var readline = require('linebyline'),
      rl = readline('./file-in-win1251.txt', {
    retainBuffer: true //tell readline to retain buffer 
  });
  rl.on("line", function (data,linecount){
    var line = iconv.decode(data, 'win1251');
    // do something with the line of converted text
  });
```
##API
## readLine(readingObject[, options])
### Params:

* `readingObject` - file path or stream object
* `options` can include:
  * `maxLineLength` - override the default 4K buffer size (lines longer than this will not be read)
  * `retainBuffer` - avoid converting to String prior to emitting 'line' event; will pass raw buffer with encoded data to the callback

### Return:

* **EventEmitter** 


## License

BSD © [Craig Brookes](http://craigbrookes.com/)

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