Created
December 8, 2019 12:55
-
-
Save mandolyte/6eaa9e43f3dd45f544f2048275e2dfd3 to your computer and use it in GitHub Desktop.
De-asynchronize does not work...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat read3.mjs | |
import csv from "fast-csv"; | |
let expected = [ | |
['Col1','Col2','Col3'], | |
['1.1','1.2','1.3'], | |
['2.1','2.2','2.3'], | |
]; | |
let input = `Col1,Col2,Col3 | |
1.1,1.2,1.3 | |
2.1,2.2,2.3 | |
`; | |
const doasync = async _ => { | |
let rows = []; | |
await csv.parseString(input,{ headers: false }) | |
.on("data", row => rows.push(row) ) | |
.on("end", rowcount => { console.log(`# rows= ${rowcount}`) } ) | |
return rows; | |
} | |
let rows = doasync().then(ar => {console.log("then:",ar)}); | |
console.log("rows=",rows); | |
$ alias nx | |
alias nx='node --experimental-modules' | |
$ nx read3.mjs | |
(node:7896) ExperimentalWarning: The ESM module loader is experimental. | |
rows= Promise { <pending> } | |
then: [] | |
# rows= 3 | |
$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment