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
Maintainers
1
Weekly downloads
14,515,136
decreased by-0.1%
Install size
5.57 kB

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

Install

$ npm install trim-newlines

Usage

import trimNewlines from 'trim-newlines';

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

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

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

API

trimNewlines(string)

Trim from the start and end of a string.

trimNewlines.start(string)

Trim from the start of a string.

trimNewlines.end(string)

Trim from the end of a string.

  • trim-left - Similar to String#trim() but removes only whitespace on the left
  • trim-right - Similar to String#trim() but removes only whitespace on the right.

Get professional support for this package with a Tidelift subscription
Tidelift helps make open source sustainable for maintainers while giving companies
assurances about security, maintenance, and licensing for their dependencies.

Keywords

FAQs

Last updated on 10 Jun 2021

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