Socket
Socket
Sign inDemoInstall

trim-newlines

Package Overview
Dependencies
0
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    trim-newlines

Trim newlines from the start and/or end of a string


Version published
Weekly downloads
15M
increased by2.23%
Maintainers
1
Install size
4.50 kB
Created
Weekly downloads
 

Package description

What is trim-newlines?

The trim-newlines npm package is used to remove newlines from the start and/or end of a string. It provides a simple way to trim newline characters from the beginning, end, or both ends of a string, which can be useful when processing text data.

What are trim-newlines's main functionalities?

Start

Removes newline characters from the start of a string.

const trimNewlines = require('trim-newlines');
console.log(trimNewlines.start('\n\nUnicorn\n'));
//=> 'Unicorn\n'

End

Removes newline characters from the end of a string.

const trimNewlines = require('trim-newlines');
console.log(trimNewlines.end('Unicorn\n\n'));
//=> 'Unicorn'

Start and End

Removes newline characters from both the start and end of a string.

const trimNewlines = require('trim-newlines');
console.log(trimNewlines('\n\nUnicorn\n\n'));
//=> 'Unicorn'

Other packages similar to trim-newlines

Readme

Source

trim-newlines

Trim newlines from the start and/or end of a string

Looking to trim all whitespace, not just newlines? Use String#trim(), String#trimStart(), or String#trimEnd().

Install

npm install trim-newlines

Usage

import {trimNewlines, trimNewlinesStart, trimNewlinesEnd} from 'trim-newlines';

trimNewlines('\n🦄\n🦄\r\n');
//=> '🦄\n🦄'

trimNewlinesStart('\n🦄\r\n');
//=> '🦄\r\n'

trimNewlinesEnd('\n🦄\r\n');
//=> '\n🦄'

API

trimNewlines(string)

Trim from the start and end of a string.

trimNewlinesStart(string)

Trim from the start of a string.

trimNewlinesEnd(string)

Trim from the end of a string.

Keywords

FAQs

Last updated on 20 Mar 2023

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc