Node.js Array to text with newline
Node.js Array to text with newline I wanted to convert an array to a textfile with a newline separating each entry. I found out about an npm package called array-to-txt-file. Here is the webpage: array-to-txt-file This package claims that will concatenate every element of the array with a newline, so that every element of the array appears on its own line on the text file. So i gave it a try and while it works great it doesn't concatenate the elements with a newline. Where one element ends, another one begins. So i took a look at the source code of the package and this is the code that creates this effect. try { array.forEach(v => { if(_.isPlainObject(v)) { ws.write(`${JSON.stringify(v)}n`) return } ws.write(`${v}n`) }) Especially the ws.write( ${v}n ) part. ws.write( ) I then imported my output text file into a hex editor. In the hex editor there was dot between each element. Now, this dot was different to a regular dot. While a regula...