Socket
Socket
Sign inDemoInstall

strip-final-newline

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

strip-final-newline

Strip the final newline character from a string/buffer


Version published
Maintainers
1
Weekly downloads
42,185,567
decreased by-9.49%

Weekly downloads

Package description

What is strip-final-newline?

The strip-final-newline npm package is a simple utility that removes the final newline character from a string. This can be useful when you want to process text data and ensure that it does not end with a newline character, which might affect the handling of the text in certain situations.

What are strip-final-newline's main functionalities?

Strip final newline from a string

This feature allows you to remove the final newline character from a given string. The code sample demonstrates how to use the strip-final-newline package to strip the newline from the end of a string.

const stripFinalNewline = require('strip-final-newline');

const stringWithNewline = 'Hello World!\n';
const stringWithoutNewline = stripFinalNewline(stringWithNewline);

console.log(stringWithoutNewline); // 'Hello World!'

Other packages similar to strip-final-newline

Readme

Source

strip-final-newline

Strip the final newline character from a string/buffer

Can be useful when parsing the output of, for example, ChildProcess#execFile, as binaries usually output a newline at the end. Normally, you would use stdout.trim(), but that would also remove newlines at the start and whitespace.

Install

$ npm install strip-final-newline

Usage

import stripFinalNewline from 'strip-final-newline';

stripFinalNewline('foo\nbar\n\n');
//=> 'foo\nbar\n'

stripFinalNewline(Buffer.from('foo\nbar\n\n')).toString();
//=> 'foo\nbar\n'

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 03 May 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