MCPcopy Create free account
hub / github.com/Inist-CNRS/node-csv-string / forEach

Function forEach

src/CSV.ts:178–211  ·  view source on GitHub ↗
(
  input: string,
  sep: Comma | ForEachCallback,
  quo?: Quote | ForEachCallback,
  callback?: ForEachCallback
)

Source from the content-addressed store, hash-verified

176 callback: ForEachCallback
177): void;
178function forEach(
179 input: string,
180 sep: Comma | ForEachCallback,
181 quo?: Quote | ForEachCallback,
182 callback?: ForEachCallback
183): void {
184 if (callback === undefined) {
185 if (quo === undefined) {
186 // arguments.length < 3) {
187 if (typeof sep !== 'function') {
188 throw Error('Last/second argument is not a callback');
189 }
190 callback = sep;
191 sep = ',';
192 } else {
193 // arguments.length < 4) {
194 if (typeof quo !== 'function') {
195 throw Error('Last/third argument is not a callback');
196 }
197 callback = quo;
198 quo = '"';
199 }
200 }
201 let i = 0;
202 let s = 0;
203 let r: number;
204 while (
205 (r = read(input.slice(s), sep as Comma, quo as Quote, (fields) =>
206 (callback as ForEachCallback)(fields, i++)
207 ))
208 ) {
209 s += r;
210 }
211}
212
213function readAll(input: string, callback: ReadAllCallback): number;
214function readAll(input: string, sep: Comma, callback: ReadAllCallback): number;

Callers

nothing calls this directly

Calls 1

readFunction · 0.85

Tested by

no test coverage detected