Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

crlf-normalize

bluelovers534.7kISC1.0.20TypeScript support: included

Detect and Normalize the newline characters

char, character, convert, cr, crlf, detect, eol, lf, line, linebreak, linefeed, newline, normalize, replace, create-by-yarn-tool, create-by-tsdx

readme

crlf-normalize

Detect and Normalize the newline characters

npm install crlf-normalize

demo

import { crlf, chkcrlf, LF, CRLF, CR } from 'crlf-normalize';

let text = 'foo\r\nbar\nbaz\r';

console.log([
    crlf(text, LF),
    crlf(text, CRLF),
    crlf(text, CR),
]);

console.log(chkcrlf(text));

/*
[ 'foo\nbar\nbaz\n', 'foo\r\nbar\r\nbaz\r\n', 'foo\rbar\rbaz\r' ]
{ lf: true, crlf: true, cr: true }
*/

crlf_unicode_normalize(text: string, newline: string = LF)

function crlf_unicode_normalize(text: string, newline: string = LF): string
{
    const ln3 = newline + newline + newline;
    const ln2 = newline + newline;

    return text
        .replace(/\u000C/g, ln3)
        .replace(/\u2028/g, newline)
        .replace(/\u2029/g, ln2)
    ;
}

changelog

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

1.0.20 (2024-01-29)

🔖 Miscellaneous

1.0.19 (2023-04-12)

🔖 Miscellaneous

1.0.18 (2022-11-01)

✨ Features

1.0.17 (2022-11-01)

✨ Features

  • add support buffer like (0e3e07c)

1.0.16 (2022-10-15)

🚨 Tests

🔖 Miscellaneous

1.0.15 (2022-09-26)

🐛 Bug Fixes

🔖 Miscellaneous

1.0.14 (2022-09-26)

🔖 Miscellaneous

1.0.13 (2022-09-16)

📦 Code Refactoring

1.0.12 (2022-08-27)

🔖 Miscellaneous

1.0.10 (2022-08-26)

🔖 Miscellaneous

1.0.9 (2022-08-26)

🔖 Miscellaneous

1.0.8 (2022-08-26)

📦 Code Refactoring

🚨 Tests

🔖 Miscellaneous

1.0.7 (2022-01-17)

📦 Code Refactoring

1.0.6 (2021-07-05)

🛠 Build System

  • typescript: importHelpers (0716543)

1.0.5 (2020-06-20)

🔖 Miscellaneous

1.0.4 (2020-06-20)

♻️ Chores

  • git: subtree add crlf-normalize (0c67bd3)

🔖 Miscellaneous

  • Add 'packages/crlf-normalize/' from commit 'c823daeb6a921b55911740de4fb370218ca5b8d1' (68ece72)