trim-newlines
TypeScript icon, indicating that this package has built-in type declarations

5.0.0 • Public • Published

trim-newlines

Trim newlines from the start and/or end of a string

Looking to trim all whitespace, not just newlines? Use String#trim(), String#trimStart(), or String#trimEnd().

Install

npm install trim-newlines

Usage

import {trimNewlines, trimNewlinesStart, trimNewlinesEnd} from 'trim-newlines';

trimNewlines('\n🦄\n🦄\r\n');
//=> '🦄\n🦄'

trimNewlinesStart('\n🦄\r\n');
//=> '🦄\r\n'

trimNewlinesEnd('\n🦄\r\n');
//=> '\n🦄'

API

trimNewlines(string)

Trim from the start and end of a string.

trimNewlinesStart(string)

Trim from the start of a string.

trimNewlinesEnd(string)

Trim from the end of a string.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 3.0.1
    8,147,668
    • 3-0-1
  • 5.0.0
    73,313
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 5.0.0
    73,313
  • 4.1.1
    1,484,026
  • 4.1.0
    34
  • 4.0.2
    209,359
  • 3.0.1
    8,147,668
  • 4.0.1
    3,889
  • 4.0.0
    141
  • 3.0.0
    355,116
  • 2.0.0
    1,110,927
  • 1.0.0
    3,423,849

Package Sidebar

Install

npm i trim-newlines

Weekly Downloads

14,808,322

Version

5.0.0

License

MIT

Unpacked Size

4.61 kB

Total Files

5

Last publish

Collaborators

  • sindresorhus