JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2208086
  • Score
    100M100P100Q227268F
  • License MIT

Remove final line feeds from a string

Package Exports

  • trim-trailing-lines
  • trim-trailing-lines/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (trim-trailing-lines) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

trim-trailing-lines

Build Coverage Downloads Size

Remove final line endings from a string.

Contents

What is this?

This is a tiny package that removes final line endings (CR, LF, CR+LF) from a string.

When should I use this?

This package is rather niche, I found myself repeating this code when working with a lot of markdown.

Install

This package is ESM only. In Node.js (version 14.14+, 16.0+), install with npm:

npm install trim-trailing-lines

In Deno with esm.sh:

import {trimTrailingLines} from 'https://esm.sh/trim-trailing-lines@2'

In browsers with esm.sh:

<script type="module">
  import {trimTrailingLines} from 'https://esm.sh/trim-trailing-lines@2?bundle'
</script>

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 identifier trimTrailingLines. There is no default export.

trimTrailingLines(value)

Remove final line endings from value.

Parameters
valeu

Value with trailing line endings, coerced to string (unknown).

Returns

Value without trailing line endings (string).

Types

This package is fully typed with TypeScript. It exports no additional types.

Compatibility

This package is at least compatible with all maintained versions of Node.js. As of now, that is Node.js 14.14+ and 16.0+. It also works in Deno and modern browsers.

Contribute

Yes please! See How to Contribute to Open Source.

Security

This package is safe.

License

MIT © Titus Wormer