title: Detecting type of line breaks
body: <p>What would be the most efficient (fast and reliable enough) way in JavaScript to determine the type of line breaks used in a text - Unix vs Windows.</p>
  
  <p>In my Node app I have to read in large utf-8 text files and then process them based on whether they use Unix or Windows line breaks.</p>
  
  <p>When the type of line breaks comes up as uncertain, I want to conclude based on which one it is most likely then.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>As per my own answer below, the <a href="https://github.com/vitaly-t/pg-minify/blob/master/lib/utils.js#L7" rel="nofollow noreferrer">code I ended up using</a>.</p>