Monday, 11 December 2017

How to write to a file with streams on infinite loop ?

Hi there.Is it possible to write to a file with streams when looping through infitiny ?Can i make this kind of code work with Node.js?let ws=require("fs").createWriteStream("dat.out",{flags:"w"}); for(;;){ let str=Array.from({length:10},(v,i)=>String.fromCharCode(65+ ~~(Math.random()*25))).join(""); ws.write(str); } I can make this with setInterval(fn,0) (fn is the function code inside for(;;) loop ) but it is not as fast as infinite for loop .Thanks .

Submitted December 11, 2017 at 08:08PM by vasifsiz

No comments:

Post a Comment