Get unlimited public & private packages + package-based permissions with npm Pro.Get started »

split-lines

2.0.0 • Public • Published

split-lines Build Status

Split lines into an array of lines

Install

$ npm install split-lines

Usage

const splitLines = require('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(input, [options])

input

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.

License

MIT © Sindre Sorhus

Install

npm i split-lines

DownloadsWeekly Downloads

36,405

Version

2.0.0

License

MIT

Unpacked Size

3.05 kB

Total Files

4

Last publish

Collaborators

  • avatar