Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
trim-off-newlines
Advanced tools
The trim-off-newlines npm package is a utility that allows you to trim newlines from the start and end of a string. It is useful for cleaning up strings that may have extraneous newline characters.
Trim newlines from the start and end of a string
This feature removes all newline characters from the beginning and end of the input string, leaving the core content intact.
const trimOffNewlines = require('trim-off-newlines');
const input = '\n\nHello, World!\n\n';
const output = trimOffNewlines(input);
console.log(output); // 'Hello, World!'
Trim newlines from the start of a string
This feature removes newline characters only from the beginning of the input string.
const trimOffNewlines = require('trim-off-newlines');
const input = '\n\nHello, World!\n\n';
const output = trimOffNewlines.start(input);
console.log(output); // 'Hello, World!\n\n'
Trim newlines from the end of a string
This feature removes newline characters only from the end of the input string.
const trimOffNewlines = require('trim-off-newlines');
const input = '\n\nHello, World!\n\n';
const output = trimOffNewlines.end(input);
console.log(output); // '\n\nHello, World!'
The trim-newlines package provides similar functionality by allowing you to trim newlines from the start and end of a string. It offers a straightforward API for removing extraneous newline characters.
The strip-newlines package removes all newline characters from a string, not just from the start and end. This can be useful if you need to completely eliminate newlines from a string.
Similar to
String#trim()
but removes only newlines
$ npm install --save trim-off-newlines
var trimOffNewlines = require('trim-off-newlines');
trimOffNewlines('\n\nunicorns\n\n');
//=> 'unicorns'
trim-left
- Similar to String#trim()
but removes only whitespace on the lefttrim-right
- Similar to String#trim()
but removes only whitespace on the rightMIT © Steve Mao
FAQs
Similar to String#trim() but removes only newlines
The npm package trim-off-newlines receives a total of 295,765 weekly downloads. As such, trim-off-newlines popularity was classified as popular.
We found that trim-off-newlines demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.