Skip to content
Remove final newline characters from a string
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.editorconfig
.gitignore
.npmrc
.prettierignore
.travis.yml
LICENSE
index.js
package.json
readme.md
test.js

readme.md

trim-trailing-lines Build Status Coverage Status

Remove final newline characters from a string.

Installation

npm:

npm install trim-trailing-lines

Usage

var trimTrailingLines = require('trim-trailing-lines')

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

API

trimTrailingLines(value)

Remove final newline characters from value.

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

string — Value without trailing newlines.

License

MIT © Titus Wormer

You can’t perform that action at this time.