# crlf-normalize

> Detect and Normalize the newline characters

Latest version **1.0.20** (published 2024-01-29) · ISC license · 0 weekly downloads

## Install

```sh
npm install crlf-normalize
pnpm add crlf-normalize
yarn add crlf-normalize
bun add crlf-normalize
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.20 |
| Published | 2024-01-29 |
| First published | 2018-01-26 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 88.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 26 |
| Author | bluelovers |
| Maintainers | bluelovers |
| Keywords | char, character, convert, cr, crlf, detect, eol, lf, line, linebreak, linefeed, newline, normalize, replace, create-by-yarn-tool, create-by-tsdx |

## Links

- npm: https://www.npmjs.com/package/crlf-normalize
- Repository: https://github.com/bluelovers/ws-string
- Homepage: https://github.com/bluelovers/ws-string/tree/master/packages/crlf-normalize#readme
- Issues: https://github.com/bluelovers/ws-string/issues
- npm.io page: https://npm.io/package/crlf-normalize

## Dependencies (1)

- [ts-type](https://npm.io/package/ts-type.md) >=2

## Alternatives

- [@gemini-wallet/core](https://npm.io/package/@gemini-wallet/core.md) — 515.6K weekly downloads
- [utility](https://npm.io/package/utility.md) — 416.6K weekly downloads
- [@primno/dpapi](https://npm.io/package/@primno/dpapi.md) — 7.2K weekly downloads
- [pi-readseek](https://npm.io/package/pi-readseek.md) — 3.7K weekly downloads
- [@emilia-protocol/verify](https://npm.io/package/@emilia-protocol/verify.md) — 1.1K weekly downloads

## Recent versions

- 1.0.20 (latest) — 2024-01-29
- 1.0.19 — 2023-04-12
- 1.0.18 — 2022-11-01
- 1.0.17 — 2022-11-01
- 1.0.16 — 2022-10-15
- 1.0.15 — 2022-09-26
- 1.0.14 — 2022-09-26
- 1.0.13 — 2022-09-16
- 1.0.12 — 2022-08-27
- 1.0.9 — 2022-08-26
- 1.0.8 — 2022-08-26
- 1.0.7 — 2022-01-17
- 1.0.6 — 2021-07-05
- 1.0.5 — 2020-06-20
- 1.0.4 — 2020-06-20
- … 4 more at https://npm.io/package/crlf-normalize/versions

## README

# crlf-normalize

> Detect and Normalize the newline characters

`npm install crlf-normalize`

## demo

```ts
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)

```ts
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)
	;
}
```

---
_Source: https://npm.io/package/crlf-normalize · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
