trim-newlines
- Version 5.0.0
- Published
- 4.61 kB
- No dependencies
- MIT license
Install
npm i trim-newlines
yarn add trim-newlines
pnpm add trim-newlines
Overview
Trim newlines from the start and/or end of a string
Index
Functions
Type Aliases
Functions
function trimNewlines
trimNewlines: <S extends string>(string: S) => Trim<S>;
Trim from the start and end of a string.
Example 1
import {trimNewlines} from 'trim-newlines';trimNewlines('\nš¦\nš¦\r\n');//=> 'š¦\nš¦'
function trimNewlinesEnd
trimNewlinesEnd: <S extends string>(string: S) => TrimEnd<S>;
Trim from the end of a string.
Example 1
import {trimNewlinesEnd} from 'trim-newlines';trimNewlinesEnd('\nš¦\r\n');//=> '\nš¦'
function trimNewlinesStart
trimNewlinesStart: <S extends string>(string: S) => TrimStart<S>;
Trim from the start of a string.
Example 1
import {trimNewlinesStart} from 'trim-newlines';trimNewlinesStart('\nš¦\r\n');//=> 'š¦\r\n'
Type Aliases
type Newline
type Newline = | '\u{A}' // '\n' | '\u{D}'; // '\r'
type Trim
type Trim<S extends string> = TrimStart<TrimEnd<S>>;
type TrimEnd
type TrimEnd<S extends string> = S extends `${infer R}${Newline}` ? TrimEnd<R> : S;
type TrimStart
type TrimStart<S extends string> = S extends `${Newline}${infer R}` ? TrimStart<R> : S;
Package Files (1)
Dependencies (0)
No dependencies.
Dev Dependencies (3)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/trim-newlines
.
- Markdown[](https://www.jsdocs.io/package/trim-newlines)
- HTML<a href="https://www.jsdocs.io/package/trim-newlines"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 3502 ms. - Missing or incorrect documentation? Open an issue for this package.