I have this function from the async module which is reading from an array of inputs files like:
inputs: ['file1.txt', 'file2.txt']
 map(inputs, fs.readFile,
   (err, contents) => {
      if (err) console.log('Error: ' + err);
      else {
        const data = contents.reduce((a, b) => a + b);
        fs.writeFile(output, data, () => console.log(`Output in file '${output}'`)
        );
      }
   }
);
How can i set a timeout to the fs.readFile call? i want this to be executed after 3 seconds for example. I was trying this for example but its not working, i guess its a syntax problem, that im not writing it like it should:
map(inputs, setTimeout(fs.readFile,3000),
       (err, contents) => {
          if (err) console.log('Error: ' + err);
          else {
            const data = contents.reduce((a, b) => a + b);
            fs.writeFile(output, data, () => console.log(`Output in file '${output}'`)
            );
          }
       }
    );
This should be easy but im stuck. Maybe i cant put the timeout inside the map function? should i create a new function, and instead of calling the fs.readFile, i call my function? Thank you in advance.
 
    