split-lines
Split lines into an array of lines
Last updated 6 years ago by sindresorhus .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install split-lines 
SYNC missed versions from official npm registry.

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.

Current Tags

  • 3.0.0                                ...           latest (6 years ago)

6 Versions

  • 3.0.0                                ...           6 years ago
  • 2.1.0                                ...           6 years ago
  • 2.0.0                                ...           9 years ago
  • 1.1.0                                ...           11 years ago
  • 1.0.0                                ...           12 years ago
  • 0.1.0                                ...           12 years ago
Maintainers (1)
Downloads
Total 25
Today 0
This Week 1
This Month 18
Last Day 0
Last Week 3
Last Month 5
Dependencies (0)
None
Dev Dependencies (3)
Dependents (2)

© 2010 - cnpmjs.org x YWFE | Home | YWFE