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
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";
Dependencies
- detect-newline: Detect the dominant newline character of a string
Dev Dependencies
- @bconnorwhite/bob: Bob builds and watches typescript projects.
- @types/node: TypeScript definitions for Node.js
- jest: Delightful JavaScript Testing.