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.15,439,7863-0-1
5.0.058,766latest

Version History

VersionDownloads (Last 7 Days)Published
5.0.058,766
4.1.1791,244
4.1.039
4.0.270,032
3.0.15,439,786
4.0.11,109
4.0.035
3.0.0187,971
2.0.0645,932
1.0.01,804,596

Package Sidebar

Install

npm i trim-newlines

Weekly Downloads

8,999,510

Version

5.0.0

License

MIT

Unpacked Size

4.61 kB

Total Files

5

Last publish

Collaborators

  • sindresorhus