'use strict';constdetectNewline=string=>{if(typeofstring!=='string'){thrownewTypeError('Expected a string');}constnewlines=string.match(/(?:\r?\n)/g)||[];if(newlines.length===0){return;}constcrlf=newlines.filter(newline=>newline==='\r\n').length;constlf=newlines.length-crlf;returncrlf>lf?'\r\n':'\n';};module.exports=detectNewline;module.exports.graceful=string=>(typeofstring==='string'&&detectNewline(string))||'\n';