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
11M
decreased by-22.56%
Maintainers
1
Install size
3.83 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 Build Status

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

Install

$ npm install --save trim-newlines

Usage

const trimNewlines = require('trim-newlines');

trimNewlines('\nunicorn\r\n');
//=> 'unicorn'

API

trimNewlines(input)

Trim from the start and end of a string.

trimNewlines.start(input)

Trim from the start of a string.

trimNewlines.end(input)

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.

License

MIT © Sindre Sorhus

Keywords

FAQs

Last updated on 22 Apr 2017

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