MCPcopy Index your code
hub / github.com/Keyang/node-csvtojson / parse

Method parse

src/rowSplit.ts:26–54  ·  view source on GitHub ↗
(fileline: Fileline)

Source from the content-addressed store, hash-verified

24 this.escape = conv.parseParam.escape;
25 }
26 parse(fileline: Fileline): RowSplitResult {
27 if (fileline.length === 0 || (this.conv.parseParam.ignoreEmpty && fileline.trim().length === 0)) {
28 return { cells: [], closed: true };
29 }
30 const quote = this.quote;
31 const trim = this.trim;
32 const escape = this.escape;
33 if (this.conv.parseRuntime.delimiter instanceof Array || this.conv.parseRuntime.delimiter.toLowerCase() === "auto") {
34 this.conv.parseRuntime.delimiter = this.getDelimiter(fileline);
35
36 }
37 if (this.needEmitDelimiter && !this.delimiterEmitted) {
38 this.conv.emit("delimiter", this.conv.parseRuntime.delimiter);
39 this.delimiterEmitted = true;
40 }
41 const delimiter = this.conv.parseRuntime.delimiter;
42 const rowArr = fileline.split(delimiter);
43 if (quote === "off") {
44 if (trim) {
45 for (let i = 0; i < rowArr.length; i++) {
46 rowArr[i] = rowArr[i].trim();
47 }
48 }
49 return { cells: rowArr, closed: true };
50 } else {
51 return this.toCSVRow(rowArr, trim, quote, delimiter);
52 }
53
54 }
55 private toCSVRow(rowArr: string[], trim: boolean, quote: string, delimiter: string): RowSplitResult {
56 const row: string[] = [];
57 let inquote = false;

Callers 15

parseMultiLinesMethod · 0.95
browser.jsFile · 0.80
vFunction · 0.80
csvtojson.min.jsFile · 0.80
vFunction · 0.80
rowSplit.jsFile · 0.80
ProcessorLocal.jsFile · 0.80
jsonTypeFunction · 0.80
ProcessFork.jsFile · 0.80
funcFunction · 0.80
rowSplit.test.tsFile · 0.80

Calls 2

getDelimiterMethod · 0.95
toCSVRowMethod · 0.95

Tested by 1

funcFunction · 0.64