MCPcopy Create free account
hub / github.com/Keyang/node-csvtojson / process

Method process

src/ProcessorLocal.ts:51–74  ·  view source on GitHub ↗
(chunk: Buffer, finalChunk = false)

Source from the content-addressed store, hash-verified

49
50 }
51 process(chunk: Buffer, finalChunk = false): Promise<ProcessLineResult[]> {
52 let csvString: string;
53 if (finalChunk) {
54 csvString = chunk.toString();
55 } else {
56 csvString = prepareData(chunk, this.converter.parseRuntime);
57
58 }
59 return Promise.resolve()
60 .then(() => {
61 if (this.runtime.preRawDataHook) {
62 return this.runtime.preRawDataHook(csvString);
63 } else {
64 return csvString;
65 }
66 })
67 .then((csv) => {
68 if (csv && csv.length > 0) {
69 return this.processCSV(csv, finalChunk);
70 } else {
71 return Promise.resolve([]);
72 }
73 })
74 }
75 private processCSV(csv: string, finalChunk: boolean): Promise<ProcessLineResult[]> {
76 const params = this.params;
77 const runtime = this.runtime;

Callers 1

flushMethod · 0.95

Calls 3

processCSVMethod · 0.95
prepareDataFunction · 0.90
thenMethod · 0.80

Tested by

no test coverage detected