Remove final newline characters from a string
Installations
npm install trim-trailing-lines
Score
99.2
Supply Chain
97.6
Quality
75.5
Maintenance
100
Vulnerability
100
License
Developer
wooorm
Developer Guide
Module System
ESM
Min. Node Version
Typescript Support
Yes
Node Version
19.0.0
NPM Version
8.19.2
Statistics
5 Stars
58 Commits
2 Forks
4 Watching
1 Branches
2 Contributors
Updated on 09 Feb 2024
Bundle Size
358.00 B
Minified
262.00 B
Minified + Gzipped
Languages
JavaScript (100%)
Total Downloads
Cumulative downloads
Total Downloads
955,290,295
Last day
-1.7%
450,694
Compared to previous day
Last week
5.6%
2,413,222
Compared to previous week
Last month
15.9%
9,729,007
Compared to previous month
Last year
-42.6%
125,259,847
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
trim-trailing-lines
Remove final line endings from a string.
Contents
- What is this?
- When should I use this?
- Install
- Use
- API
- Types
- Compatibility
- Contribute
- Security
- License
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:
1npm install trim-trailing-lines
In Deno with esm.sh
:
1import {trimTrailingLines} from 'https://esm.sh/trim-trailing-lines@2'
In browsers with esm.sh
:
1<script type="module"> 2 import {trimTrailingLines} from 'https://esm.sh/trim-trailing-lines@2?bundle' 3</script>
Use
1import {trimTrailingLines} from 'trim-trailing-lines' 2 3trimTrailingLines('foo\nbar') // => 'foo\nbar' 4trimTrailingLines('foo\nbar\n') // => 'foo\nbar' 5trimTrailingLines('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
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: license:0
- Info: FSF or OSI recognized license: MIT License: license:0
Reason
0 existing vulnerabilities detected
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:10: update your workflow using https://app.stepsecurity.io/secureworkflow/wooorm/trim-trailing-lines/main.yml/main?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:11: update your workflow using https://app.stepsecurity.io/secureworkflow/wooorm/trim-trailing-lines/main.yml/main?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/main.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/wooorm/trim-trailing-lines/main.yml/main?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/main.yml:15
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 1 third-party GitHubAction dependencies pinned
- Info: 0 out of 1 npmCommand dependencies pinned
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/main.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
Project has not signed or included provenance with any releases.
Details
- Warn: release artifact 1.1.4 not signed: https://api.github.com/repos/wooorm/trim-trailing-lines/releases/33151953
- Warn: release artifact 1.1.3 not signed: https://api.github.com/repos/wooorm/trim-trailing-lines/releases/23122999
- Warn: release artifact 1.1.2 not signed: https://api.github.com/repos/wooorm/trim-trailing-lines/releases/17289931
- Warn: release artifact 1.1.4 does not have provenance: https://api.github.com/repos/wooorm/trim-trailing-lines/releases/33151953
- Warn: release artifact 1.1.3 does not have provenance: https://api.github.com/repos/wooorm/trim-trailing-lines/releases/23122999
- Warn: release artifact 1.1.2 does not have provenance: https://api.github.com/repos/wooorm/trim-trailing-lines/releases/17289931
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'main'
Score
3.1
/10
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More