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

Function processLineByLine

src/Result.ts:85–140  ·  view source on GitHub ↗
(
  lines: ProcessLineResult[],

  conv: Converter,
  offset: number,
  needPushDownstream: boolean,
  cb: (err?) => void,
)

Source from the content-addressed store, hash-verified

83}
84
85function processLineByLine(
86 lines: ProcessLineResult[],
87
88 conv: Converter,
89 offset: number,
90 needPushDownstream: boolean,
91 cb: (err?) => void,
92) {
93 if (offset >= lines.length) {
94 cb();
95 } else {
96 if (conv.parseRuntime.subscribe && conv.parseRuntime.subscribe.onNext) {
97 const hook = conv.parseRuntime.subscribe.onNext;
98 const nextLine = lines[offset];
99 const res = hook(nextLine, conv.parseRuntime.parsedLineNumber + offset);
100 offset++;
101 // if (isAsync === undefined) {
102 if (res && res.then) {
103 res.then(function () {
104 processRecursive(lines, hook, conv, offset, needPushDownstream, cb, nextLine);
105 }, cb);
106 } else {
107 // processRecursive(lines, hook, conv, offset, needPushDownstream, cb, nextLine, false);
108 if (needPushDownstream) {
109 pushDownstream(conv, nextLine);
110 }
111 while (offset < lines.length) {
112 const line = lines[offset];
113 hook(line, conv.parseRuntime.parsedLineNumber + offset);
114 offset++;
115 if (needPushDownstream) {
116 pushDownstream(conv, line);
117 }
118 }
119 cb();
120 }
121 // } else if (isAsync === true) {
122 // (res as PromiseLike<void>).then(function () {
123 // processRecursive(lines, hook, conv, offset, needPushDownstream, cb, nextLine, true);
124 // }, cb);
125 // } else if (isAsync === false) {
126 // processRecursive(lines, hook, conv, offset, needPushDownstream, cb, nextLine, false);
127 // }
128 } else {
129 if (needPushDownstream) {
130 while (offset < lines.length) {
131 const line = lines[offset++];
132 pushDownstream(conv, line);
133 }
134
135 }
136 cb();
137 }
138
139 }
140}
141
142function processRecursive(

Callers 2

processResultMethod · 0.70
processRecursiveFunction · 0.70

Calls 3

thenMethod · 0.80
processRecursiveFunction · 0.70
pushDownstreamFunction · 0.70

Tested by

no test coverage detected