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

Function readChunk

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

Source from the content-addressed store, hash-verified

260 callback: ReadAllCallback
261): number;
262function readChunk(
263 input: string,
264 sep: Comma | ReadAllCallback,
265 quo?: Quote | ReadAllCallback,
266 callback?: ReadAllCallback
267): number {
268 if (callback === undefined) {
269 if (quo === undefined) {
270 // arguments.length < 3) {
271 if (typeof sep !== 'function') {
272 throw Error('Last/second argument is not a callback');
273 }
274 callback = sep;
275 sep = ',';
276 } else {
277 // arguments.length < 4) {
278 if (typeof quo !== 'function') {
279 throw Error('Last/third argument is not a callback');
280 }
281 callback = quo;
282 quo = '"';
283 }
284 }
285 const csv = new Parser(input, sep as Comma, quo as Quote);
286 const rows = csv.File();
287 let ret = 0;
288 if (csv.pointer < input.length) {
289 ret = csv.pointer;
290 } else {
291 rows.pop();
292 ret = csv.linePointer;
293 }
294 callback(rows);
295 return ret;
296}
297
298const fetch = (input: string, sep?: Comma, quo?: Quote): Value[] => {
299 // TODO

Callers

nothing calls this directly

Calls 1

FileMethod · 0.95

Tested by

no test coverage detected