frontend/.pnpm-store/v3/files/d3/9796f359c16f69fdf2e9aa325747bb309a6e8688cf1c1246be6cbcf4007cb8caa583f8ab95ae47ee8cfa71f3b72b3f0c658a18f3d4c2b9da4d59119bf282fe

25 lines
742 B
Plaintext

import { ParseRuntime } from "./ParseRuntime";
import getEol from "./getEol";
// const getEol = require("./getEol");
/**
* convert data chunk to file lines array
* @param {string} data data chunk as utf8 string
* @param {object} param Converter param object
* @return {Object} {lines:[line1,line2...],partial:String}
*/
export function stringToLines(data: string, param: ParseRuntime): StringToLinesResult {
const eol = getEol(data, param);
const lines = data.split(eol);
const partial = lines.pop() || "";
return { lines: lines, partial: partial };
};
export interface StringToLinesResult {
lines: Fileline[],
/**
* last line which could be incomplete line.
*/
partial: string
}
export type Fileline = string;