UNPKG

@royli/hygen

Version:

The scalable code generator that saves you time.

14 lines (13 loc) 435 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const os_1 = require("os"); const newline = (string) => { const newlines = string.match(/(?:\r?\n)/g) || []; if (newlines.length === 0) { return os_1.EOL; } const crlf = newlines.filter((newline) => newline === '\r\n').length; const lf = newlines.length - crlf; return crlf > lf ? '\r\n' : '\n'; }; exports.default = newline;