I have a Map that I had been told was better to use than a JS Array [].
Now, I'm working on debugging some of the data being parsed through.
const Csv2Map_Promise = (async (csvFilepath) => {
return new Promise((resolve) => {
const csvData = new Map();
createReadStream(csvFilepath)
.pipe(parse({ delimiter: ',' }))
.on('data', (csvRow) => { csvData.set(csvRow[0], { 'value 1': 1, 'value 2': 2, 'value 3': 3, 'value 4': 4 }); })
.on('end', () => { resolve(csvData); });
});
})
const csvFile1_Map = Csv2Map_Promise('csvFile1.csv');
csvFile1_Map.then(()=>{console.log(csvFile1_Map);})
The files I'm debugging are really big.
How can I console.log just some of the data?
(Check like 10 or 100 returns)
P.S. I know I can convert back to an array,
But is there a better way? Or am I just fooling myself?