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

Function processLineByLine

v2/Result.js:96–145  ·  view source on GitHub ↗
(lines, conv, offset, needPushDownstream, cb)

Source from the content-addressed store, hash-verified

94}());
95exports.Result = Result;
96function processLineByLine(lines, conv, offset, needPushDownstream, cb) {
97 if (offset >= lines.length) {
98 cb();
99 }
100 else {
101 if (conv.parseRuntime.subscribe && conv.parseRuntime.subscribe.onNext) {
102 var hook_1 = conv.parseRuntime.subscribe.onNext;
103 var nextLine_1 = lines[offset];
104 var res = hook_1(nextLine_1, conv.parseRuntime.parsedLineNumber + offset);
105 offset++;
106 // if (isAsync === undefined) {
107 if (res && res.then) {
108 res.then(function () {
109 processRecursive(lines, hook_1, conv, offset, needPushDownstream, cb, nextLine_1);
110 }, cb);
111 }
112 else {
113 // processRecursive(lines, hook, conv, offset, needPushDownstream, cb, nextLine, false);
114 if (needPushDownstream) {
115 pushDownstream(conv, nextLine_1);
116 }
117 while (offset < lines.length) {
118 var line = lines[offset];
119 hook_1(line, conv.parseRuntime.parsedLineNumber + offset);
120 offset++;
121 if (needPushDownstream) {
122 pushDownstream(conv, line);
123 }
124 }
125 cb();
126 }
127 // } else if (isAsync === true) {
128 // (res as PromiseLike<void>).then(function () {
129 // processRecursive(lines, hook, conv, offset, needPushDownstream, cb, nextLine, true);
130 // }, cb);
131 // } else if (isAsync === false) {
132 // processRecursive(lines, hook, conv, offset, needPushDownstream, cb, nextLine, false);
133 // }
134 }
135 else {
136 if (needPushDownstream) {
137 while (offset < lines.length) {
138 var line = lines[offset++];
139 pushDownstream(conv, line);
140 }
141 }
142 cb();
143 }
144 }
145}
146function processRecursive(lines, hook, conv, offset, needPushDownstream, cb, res) {
147 if (needPushDownstream) {
148 pushDownstream(conv, res);

Callers 2

Result.jsFile · 0.70
processRecursiveFunction · 0.70

Calls 3

thenMethod · 0.80
processRecursiveFunction · 0.70
pushDownstreamFunction · 0.70

Tested by

no test coverage detected