I am trying to write the contents of a Map to a text file, but am getting an error. Here is my code:
const dictionary = new Map()
dictionary['foo'] = 10
dictionary['test'] = 5
dictionary['sample'] = 7
require('fs').writeFile('textFile.txt', dictionary, (error) => {
if(error) throw err
})
The error I get says that I cannot write a Map as the 'data' argument must be of type string or an instance of Buffer, TypedArray, or DataView. Is there a way that I can write the contents of my Map to the 'textFile.txt' file?