Socket
Socket
Sign inDemoInstall

crlf-normalize

Package Overview
Dependencies
6
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    crlf-normalize

Detect and Normalize the newline characters


Version published
Maintainers
1
Install size
2.26 MB
Created

Readme

Source

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

Keywords

FAQs

Last updated on 29 Jan 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc