terminating-newline
Add or remove a terminating newline
Last updated 4 years ago by bconnorwhite .
MIT · Repository · Original npm · Tarball · package.json
$ gnpm install terminating-newline 
SYNC missed versions from official npm registry.

terminating-newline

NPM TypeScript Coverage Status

Add or remove a terminating newline.

If I should maintain this repo, please ⭐️ GitHub stars

DM me on Twitter if you have questions or suggestions. Twitter


Supports both line feeds (/n) and carriage return line feeds (/r/n). Will only add a newline if one does not already exist.

Installation

yarn add terminating-newline
npm install terminating-newline
pnpm add terminating-newline

API

Usage

import {
  addTerminatingNewline,
  removeTerminatingNewline,
  lineFeed, // "\n"
  carriageReturnLineFeed // "/r/n"
} from "terminating-newline";

addTerminatingNewline("abc", { default: lineFeed }); // "abc/n"

addTerminatingNewline("abc\n", { default: lineFeed }); // "abc/n"

removeTerminatingNewline("abc\n"); // "abc"

Types

function addTerminatingNewline(string: string, options?: Options): string;
function addTerminatingNewline(buffer: Buffer, options?: Options): Buffer;

function removeTerminatingNewline(string: string): string;
function removeTerminatingNewline(buffer: Buffer): Buffer;

type Options = {
  // Fallback if newline type cannot be determined. Default: "\n"
  default?: LineFeed | CarriageReturnLineFeed;
}

type LineFeed = "\n";

type CarriageReturnLineFeed = "\r\n";

Dependenciesdependencies


Dev Dependencies

  • autorepo: Autorepo abstracts away your dev dependencies, providing a single command to run all of your scripts.

License license

MIT

Current Tags

  • 2.0.0                                ...           latest (2 years ago)

11 Versions

  • 2.0.0                                ...           2 years ago
  • 1.2.4                                ...           4 years ago
  • 1.2.3                                ...           4 years ago
  • 1.2.2                                ...           4 years ago
  • 1.2.1                                ...           4 years ago
  • 1.2.0                                ...           4 years ago
  • 1.1.2                                ...           4 years ago
  • 1.1.1                                ...           4 years ago
  • 1.1.0                                ...           4 years ago
  • 1.0.1                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
Downloads
Today 0
This Week 0
This Month 8
Last Day 0
Last Week 8
Last Month 0
Dependencies (2)
Dev Dependencies (1)

Copyright 2013 - present © cnpmjs.org | Home |