JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4045
  • Score
    100M100P100Q178139F
  • License MIT

Add or remove a terminating newline

Package Exports

  • terminating-newline

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (terminating-newline) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

terminating-newline

npm typescript GitHub stars Twitter Follow

Add or remove a terminating newline.

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

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. Defaults to "\n".
  default?: LineFeed | CarriageReturnLineFeed;
}

type LineFeed = "\n";

type CarriageReturnLineFeed = "\r\n";


Dependenciesdependencies


Dev DependenciesDavid


License license

MIT