# Code coverage report for csv2json/src/getEol.ts

# All files / csv2json/src getEol.ts

0% Statements 0/0
0% Branches 3/3
0% Functions 0/0
0% Lines 0/0

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
    22

     import { ParseRuntime } from "./ParseRuntime";
    //return first eol found from a data chunk.
    export default function (data: string, param: ParseRuntime): string {
      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";
              break;
            } else if (data[i + 1]) {
              param.eol = "\r";
              break;
            }
          } else if (data[i] === "\n") {
            param.eol = "\n";
            break;
          }
        }
      }
      return param.eol || "\n";
    };