# split-lines

> Split lines into an array of lines

Latest version **3.0.0** (published 2021-04-08) · MIT license · 0 weekly downloads

> **Better alternative:** Use str.split(/\r?\n/) — Consider using a lighter alternative

## Install

```sh
npm install split-lines
pnpm add split-lines
yarn add split-lines
bun add split-lines
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2021-04-08 |
| First published | 2014-06-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Node | >=12 |
| Dependencies | 0 |
| Unpacked size | 3.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 48 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | split, lines, line, string, str, newline, newlines, linebreak, line-break, lf, crlf, eol, linefeed |

## Links

- npm: https://www.npmjs.com/package/split-lines
- Repository: https://github.com/sindresorhus/split-lines
- Homepage: https://github.com/sindresorhus/split-lines#readme
- Issues: https://github.com/sindresorhus/split-lines/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/split-lines

## Alternatives

- [@sveltejs/kit](https://npm.io/package/@sveltejs/kit.md) — 2.2M weekly downloads
- [@atlaskit/theme](https://npm.io/package/@atlaskit/theme.md) — 402.0K weekly downloads
- [@tangle-network/brand](https://npm.io/package/@tangle-network/brand.md) — 10.0K weekly downloads
- [seneca](https://npm.io/package/seneca.md) — 7.4K weekly downloads
- [@bsb/base](https://npm.io/package/@bsb/base.md) — 7.2K weekly downloads

## Recent versions

- 3.0.0 (latest) — 2021-04-08
- 2.1.0 — 2021-03-24
- 2.0.0 — 2018-05-18
- 1.1.0 — 2016-05-23
- 1.0.0 — 2014-08-13
- 0.1.0 — 2014-06-28

## README

# split-lines

> Split lines into an array of lines

## Install

```
$ npm install split-lines
```

## Usage

```js
import splitLines from 'split-lines';

splitLines('foo\r\nbar\r\nbaz\nrainbow');
//=> ['foo', 'bar', 'baz', 'rainbow']

splitLines('foo\r\nbar\r\nbaz\nrainbow', {preserveNewlines: true});
//=> ['foo\r\n', 'bar\r\n', 'baz\n', 'rainbow']
```

## API

### splitLines(string, options?)

#### string

Type: `string`

String to split.

#### options

Type: `object`

##### preserveNewlines

Type: `boolean`\
Default: `false`

Preserve the line separator at the end of every line, except the last line, which will never contain one.

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