# readl

> Read a file line-by-line

Latest version **0.0.8** (published 2016-10-25) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

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

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.0.8 |
| Published | 2016-10-25 |
| First published | 2016-08-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Josemi Juanes |
| Maintainers | jmjuanes |
| Keywords | file, read, line, line-by-line, fs, readline, linebyline, readl, readlines |

## Links

- npm: https://www.npmjs.com/package/readl
- Repository: https://github.com/jmjuanes/readl
- Homepage: https://github.com/jmjuanes/readl#readme
- Issues: https://github.com/jmjuanes/readl/issues
- npm.io page: https://npm.io/package/readl

## Dependencies (1)

- [pstat](https://npm.io/package/pstat.md) 1.0.2

## 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

- 0.0.8 (latest) — 2016-10-25
- 0.0.7 — 2016-10-24
- 0.0.6 — 2016-10-03
- 0.0.5 — 2016-10-03
- 0.0.4 — 2016-10-03
- 0.0.3 — 2016-10-02
- 0.0.2 — 2016-09-14
- 0.0.1 — 2016-08-08

## README

# readl

> Read a file line-by-line in node.js

[![npm](https://img.shields.io/npm/v/readl.svg?style=flat-square)](https://www.npmjs.com/package/readl)
[![npm](https://img.shields.io/npm/dt/readl.svg?style=flat-square)](https://www.npmjs.com/package/readl)

## Install

You can install the latest version of the package using **npm**:

```
$ npm install --save readl
```

## Usage

```javascript
//Import dependencies
var readl = require('readl');

//File content
var content = '';

//Read the file
readl('file.txt', { encoding: 'utf8', start: 0 }, function(line)
{
  //Save the file content
  content = content + line + '\n';
});

//Show the file content
console.log(content);
```

## API

### readl(file, options, callback)

Execute the `callback` function one time for each line on the `file`.

##### file

A `string` with the path to the file.

##### options

An `object` with the following options:

- `encoding`: set the encoding. Default: `utf8`.
- `emptyLines`: set it to `false` if you want to omit the empty lines. Default: `true`.
- `start`: start position. Default is 0.
- `chunk`: set the chunk size. Default is 1024.
- `endl`: set the end-line character. Default is `0x0a`.

##### callback

A `function` that will be executed one time for each read line on the file. This function will pass the following arguments:

- `line`: a `string` with the read line.
- `index`: an `integer` with the line number. The line counter starts in 1.
- `position_start`: an `integer` with the start position of the line in the file.
- `position_end`: an `integer` with the end position of the line in the file.
- `length`: an `integer` with the number of bytes read.

You can break the loop at a particular line by making the callback function return `false`.  


## Related

- [readl-async](https://github.com/jmjuanes/readl-async): asynchronous version of this module.

## License

[MIT](./LICENSE) &copy; Josemi Juanes.

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