Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rexxars/linecount
Count number of lines in a file or stream
https://github.com/rexxars/linecount
Last synced: 10 days ago
JSON representation
Count number of lines in a file or stream
- Host: GitHub
- URL: https://github.com/rexxars/linecount
- Owner: rexxars
- License: mit
- Created: 2016-12-08T15:29:38.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2016-12-08T15:30:34.000Z (almost 8 years ago)
- Last Synced: 2024-06-11T17:37:48.938Z (5 months ago)
- Language: JavaScript
- Size: 14.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# linecount
Counts number of lines in a file (or a stream)
## Installation
```
npm install --save linecount
```## Usage
```js
var linecount = require('linecount')linecount('/usr/share/dict/words', (err, count) => {
if (err) {
throw err
}console.log(count) // 99171
})// Or, promised:
var linecount = require('linecount/promise')linecount('/usr/share/dict/words')
.then(count => console.log(count))
.catch(err => console.error(err))// You can also pass a stream. Note that this will drain the stream though, so you can't read from the same stream after counting it:
linecount(fs.createReadStream('/usr/share/dict/words'))
.then(count => console.log(count))
.catch(err => console.error(err))
```## License
MIT-licensed. See LICENSE.