# readfileline

> read file line by line

Latest version **2.0.4** (published 2015-07-10) · MIT license · 0 weekly downloads

## Install

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

## 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 | 2.0.4 |
| Published | 2015-07-10 |
| First published | 2015-07-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | zenboss |
| Maintainers | zenboss |
| Keywords | readline, readfile, fileline |

## Links

- npm: https://www.npmjs.com/package/readfileline
- Repository: https://github.com/zenboss/readfileline
- Issues: https://github.com/zenboss/readfileline/issues
- npm.io page: https://npm.io/package/readfileline

## Alternatives

- [localforage](https://npm.io/package/localforage.md) — 6.2M weekly downloads
- [localforage-observable](https://npm.io/package/localforage-observable.md) — 30.8K weekly downloads
- [@y/y](https://npm.io/package/@y/y.md) — 30.1K weekly downloads
- [@metaobjectsdev/render](https://npm.io/package/@metaobjectsdev/render.md) — 3.5K weekly downloads
- [@ledgerhq/coin-algorand](https://npm.io/package/@ledgerhq/coin-algorand.md) — 1.1K weekly downloads

## Recent versions

- 2.0.4 (latest) — 2015-07-10
- 2.0.3 — 2015-07-10
- 2.0.2 — 2015-07-10
- 2.0.1 — 2015-07-10
- 1.0.0 — 2015-07-02

## README

# ReadFileLine

Read file line by line for node

[![Build Status](https://travis-ci.org/zenboss/readfileline.svg?branch=master)](https://travis-ci.org/zenboss/readfileline) [![Build status](https://ci.appveyor.com/api/projects/status/ptyb3ttjqvdfyui1?svg=true)](https://ci.appveyor.com/project/zenboss/readfileline)


# Install
>$ npm install readfileline -g

# How to use

``` javascript
var fl = require('readfileline');
var fileContents = [];
fl(__dirname+'/data.txt',function(lineData,lineNum){
    fileContents.push(lineData);
    console.log(lineNum+':'+lineData+'\n');
},function(err,eventType,totalLineNum){
    if(eventType=='end'){
    	//if file read all line to success, "close" event still will emit, so you need distinguish between they
    	console.log('read line is done, total '+totalLineNum+' line(s)');
    }
	if(eventType=='close'){
		console.log('read line is closed, read to '+totalLineNum+' line(s)');
	}
    if(eventType=='error'){
    	console.log('read file line has an error:'+err.message);
    }
});

//--------

var fileContents2=[];
fl(__dirname+'/data.txt',function(lineData,lineNum){
	var thisFL = this;
	if(lineNum>=5){
		this.close(); //And also has a function is "this.stop()", but it still emit "close" event so you still need listen "close" event, so mustn't listen "stop" event
		return;
	}
    fileContents2.push(lineData);
    console.log(lineNum+':'+lineData+'\n');
},function(err,eventType,totalLineNum){
    if(eventType=='end'){
    	//if file read all line to success, "close" event still will emit, so you need distinguish between they
    	console.log('read line is done, total '+totalLineNum+' line(s)');
    }
	if(eventType=='close'){
		console.log('read line is closed, read to '+totalLineNum+' line(s)');
	}
    if(eventType=='error'){
    	console.log('read file line has an error:'+err.message);
    }
});
```

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