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

VersionDownloads (Last 7 Days)Tag
3.0.17,784,1193-0-1
5.0.080,486latest

Version History

VersionDownloads (Last 7 Days)Published
5.0.080,486
4.1.11,027,915
4.1.073
4.0.2130,408
3.0.17,784,119
4.0.11,777
4.0.0288
3.0.0509,935
2.0.01,270,984
1.0.02,712,604

Package Sidebar

Install

npm i trim-newlines

Weekly Downloads

13,518,589

Version

5.0.0

License

MIT

Unpacked Size

4.61 kB

Total Files

5

Last publish

Collaborators

  • sindresorhus