Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
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 255,880 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.