util.rstrip

Removes newline characters from the right of a string

Usage no npm install needed!

<script type="module">
  import utilRstrip from 'https://cdn.skypack.dev/util.rstrip';
</script>

README

util.rstrip

Removes newline characters from the right of a string

build analysis code style: prettier testing NPM

Removes the \n, \r, or \r\n from the end of a string or Buffer and returns the new string.

Installation

This module uses yarn to manage dependencies and run scripts for development.

To install as a development dependency:

$ yarn add --dev util.rstrip

To build the app and run all tests:

$ yarn run all

Example Usage

From String

const rstrip = require('util.rstrip');
let s = rstrip('This is a test\r\n');

// returns the string "This is a test" without newlines

From Buffer

const rstrip = require('util.rstrip');
let buf = new Buffer('This is a test\r\n');
let s = rstrip(buf);

// returns the string "This is a test" without newlines