UNPKG

@visulima/fs

Version:

Human friendly file system utilities for Node.js

21 lines (18 loc) 710 B
import { platform } from '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 = 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"); export { CRLF, EOL, LF, detect, format };