]> git.ardis.lu - csvio/commitdiff
Explicitly await for stream close
authorArdis Lu <ardisglu@gmail.com>
Fri, 10 Jan 2025 05:45:15 +0000 (21:45 -0800)
committerArdis Lu <ardisglu@gmail.com>
Fri, 10 Jan 2025 05:45:15 +0000 (21:45 -0800)
Otherwise, a race condition occurs when running these examples in test cases

examples/ex1.js
examples/ex2.js
examples/ex3.js
examples/ex4.js
examples/ex5.js

index b2457d9c8ab5df7ffdf5749716e361f5207dc582..d08d007d4b1961cfa763e8aa2c14e812b3db4ade 100644 (file)
@@ -14,6 +14,6 @@ function timesTwo(row) {
   return [Number(row[0]) * 2, Number(row[1]) * 2];
 }
 
-createCSVReadableStream(new URL('./data/ex1-in.csv', import.meta.url))
+await createCSVReadableStream(new URL('./data/ex1-in.csv', import.meta.url))
   .pipeThrough(createCSVTransformStream(timesTwo))
   .pipeTo(createCSVWritableStream(new URL('./data/ex1-out.csv', import.meta.url)));
\ No newline at end of file
index 16c1c606eae59ad65819d42c13b57e41d0257b5b..dfedb32beee3a328f319cdf63c81b2522834f20d 100644 (file)
@@ -18,6 +18,6 @@ function sum(row) {
   return [...row, Number(row[0]) + Number(row[1])];
 }
 
-createCSVReadableStream(new URL('./data/ex2-in.csv', import.meta.url))
+await createCSVReadableStream(new URL('./data/ex2-in.csv', import.meta.url))
   .pipeThrough(createCSVTransformStream(sum, { includeHeaders: true }))
   .pipeTo(createCSVWritableStream(new URL('./data/ex2-out.csv', import.meta.url)));
\ No newline at end of file
index 32a907d61f1a8aac6693c04b17fcc7fa76efea1e..85a3c821a3d2d19dbfa36b5739406874124f08a4 100644 (file)
@@ -22,7 +22,7 @@ function calculate(obj) {
   return [name, paddedId];
 }
 
-createCSVReadableStream(new URL('./data/ex3-in.csv', import.meta.url))
+await createCSVReadableStream(new URL('./data/ex3-in.csv', import.meta.url))
   .pipeThrough(createCSVTransformStream(parse, { includeHeaders: true, rawOutput: true }))
   .pipeThrough(createCSVTransformStream(calculate, { includeHeaders: true, rawInput: true }))
   .pipeTo(createCSVWritableStream(new URL('./data/ex3-out.csv', import.meta.url)));
\ No newline at end of file
index 638605f39a7849801d22c7175af2ecc2b0c0f843..9039354db5d4ec6b6444d8590805ca0ef70635cd 100644 (file)
@@ -30,7 +30,7 @@ const headers = [
   }
 ];
 
-createCSVReadableStream(new URL('./data/ex4-in.csv', import.meta.url))
+await createCSVReadableStream(new URL('./data/ex4-in.csv', import.meta.url))
   .pipeThrough(createCSVNormalizationStream(headers))
   .pipeThrough(createCSVDenormalizationStream())
   .pipeTo(createCSVWritableStream(new URL('./data/ex4-out.csv', import.meta.url)));
\ No newline at end of file
index 2b0f9a383130f3233788c15d3ac435bf4679e5a7..7d8b5eb0c7411554b87e5cf82c904eeb9f5ae8dd 100644 (file)
@@ -24,6 +24,6 @@ function parse(row) {
   return [report, id, date, ...row];
 }
 
-createCSVReadableStream(new URL('./data/ex5-in.csv', import.meta.url))
+await createCSVReadableStream(new URL('./data/ex5-in.csv', import.meta.url))
   .pipeThrough(createCSVTransformStream(parse, { includeHeaders: true }))
   .pipeTo(createCSVWritableStream(new URL('./data/ex5-out.csv', import.meta.url)));
\ No newline at end of file
This page took 0.041712 seconds and 4 git commands to generate.