All files / csv2json/libs/core getEol.js

0% Statements 0/14
0% Branches 0/12
0% Functions 0/1
0% Lines 0/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21                                         
//return eol from a data chunk.
var eol = require("os").EOL;
module.exports = function(data, param) {
  if (!param.eol && data) {
    for (var i = 0, len = data.length; i < len; i++) {
      if (data[i] === "\r") {
        if (data[i + 1] === "\n") {
          param.eol = "\r\n";
        } else if (data[i + 1]) {
          param.eol = "\r";
        }
        return param.eol;
      } else if (data[i] === "\n") {
        param.eol = "\n";
        return param.eol;
      }
    }
  }
  return param.eol;
};