Skip to content
main
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

trim-trailing-lines

Build Coverage Downloads Size

Remove final line feeds from a string.

Install

This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required.

npm:

npm install trim-trailing-lines

Use

import {trimTrailingLines} from 'trim-trailing-lines'

trimTrailingLines('foo\nbar') // => 'foo\nbar'
trimTrailingLines('foo\nbar\n') // => 'foo\nbar'
trimTrailingLines('foo\nbar\n\n') // => 'foo\nbar'

API

This package exports the following identifiers: trimTrailingLines. There is no default export.

trimTrailingLines(value)

Remove final line feed characters from value.

Parameters
  • value (string) — Value with trailing line feeds, coerced to string.
Returns

string — Value without trailing newlines.

License

MIT © Titus Wormer

About

Remove final newline characters from a string

Topics

Resources

License

Sponsor this project

 

Packages

No packages published