daily pastebin goal
22%
SHARE
TWEET

Untitled

a guest Feb 20th, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function asyncInsertMagFromFile(file, resolve) {
  2.             //some asynchronous processing with file
  3.             resolve();
  4.           }
  5.  
  6. let magRequests = fs.readdirSync(storeDir).map(function(file) {
  7.             return new Promise(resolve => {
  8.               asyncInsertMagFromFile(file, resolve);
  9.             });
  10.           });
  11.      
  12. (async function loop() {
  13.             fs.readdirSync(storeDir).forEach(function(file) {
  14.               await new Promise(resolve =>
  15.                 asyncInsertMagFromFile(file, resolve)
  16.               );
  17.             });
  18.  
  19.           })();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top