Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ngryman/lines-iterator
Iterates over lines, es6 way.
https://github.com/ngryman/lines-iterator
Last synced: 21 days ago
JSON representation
Iterates over lines, es6 way.
- Host: GitHub
- URL: https://github.com/ngryman/lines-iterator
- Owner: ngryman
- License: mit
- Created: 2016-07-04T02:15:42.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-10-14T23:54:05.000Z (about 7 years ago)
- Last Synced: 2024-10-02T07:21:09.077Z (about 1 month ago)
- Language: JavaScript
- Homepage:
- Size: 11.7 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: readme.md
- License: license
Awesome Lists containing this project
README
# Lines Iterator
> Iterates over lines, es6 way.
[![travis][travis-image]][travis-url] [![codecov][codecov-image]][codecov-url]
[travis-image]: https://img.shields.io/travis/ngryman/lines-iterator.svg?style=flat
[travis-url]: https://travis-ci.org/ngryman/lines-iterator
[codecov-image]: https://img.shields.io/codecov/c/github/ngryman/lines-iterator.svg
[codecov-url]: https://codecov.io/github/ngryman/lines-iterator**lines-iterator** allows you to iterate over lines via a `es6` iterator.
## Install
```bash
npm install --save lines-iterator
```## Usage
```javascript
const lines = require('lines-iterator')for (let line of lines('first\nsecond')) {
console.log(`LINE: ${line}`)
}// => LINE: first
// => LINE: second
```## API
### `lines(text[, options])`
#### `text` `{string}`
Text containing `eol` characters.
#### `options` `{object}`
##### `ignoreEmpty` `{boolean}`
Ignore empty lines.
```javascript
const text = `
firstsecond
`for (let line of lines(text, { ignoreEmpty: true })) {
console.log(`LINE: ${lines}`)
}// => LINE: first
// => LINE: second
```## License
MIT © [Nicolas Gryman](http://ngryman.sh)