split-lines
TypeScript icon, indicating that this package has built-in type declarations

3.0.0 • Public • Published

split-lines

Split lines into an array of lines

Install

$ npm install split-lines

Usage

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.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 3.0.0
    18,564
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 3.0.0
    18,564
  • 2.1.0
    71,714
  • 2.0.0
    2,922
  • 1.1.0
    32,220
  • 1.0.0
    1
  • 0.1.0
    1

Package Sidebar

Install

npm i split-lines

Weekly Downloads

125,422

Version

3.0.0

License

MIT

Unpacked Size

3.63 kB

Total Files

5

Last publish

Collaborators

  • sindresorhus