UNPKG

@visulima/fs

Version:

Human friendly file system utilities for Node.js

29 lines (24 loc) 919 B
'use strict'; Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } }); const node_process = require('node:process'); var __defProp = Object.defineProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); const regDetect = /\r?\n/g; const LF = "\n"; const CRLF = "\r\n"; const EOL = node_process.platform === "win32" ? CRLF : LF; const detect = /* @__PURE__ */ __name((content) => { const d = content.match(regDetect); if (!d || d.length === 0) { return null; } const crlf = d.filter((newline) => newline === CRLF).length; const lf = d.length - crlf; return crlf > lf ? CRLF : LF; }, "detect"); const format = /* @__PURE__ */ __name((content, eol) => content.replaceAll(regDetect, eol), "format"); exports.CRLF = CRLF; exports.EOL = EOL; exports.LF = LF; exports.detect = detect; exports.format = format;