Product
Introducing Java Support in Socket
We're excited to announce that Socket now supports the Java programming language.
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
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.
Product
We're excited to announce that Socket now supports the Java programming language.
Security News
Socket detected a malicious Python package impersonating a popular browser cookie library to steal passwords, screenshots, webcam images, and Discord tokens.
Security News
Deno 2.0 is now available with enhanced package management, full Node.js and npm compatibility, improved performance, and support for major JavaScript frameworks.