Advertisement
Guest User

Untitled

a guest
Feb 5th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. ```js
  2. // es6a.js
  3.  
  4. await foo(); // takes 10 milliseconds
  5.  
  6. require('./y.js');
  7. ```
  8.  
  9. ```js
  10. // es6b.js
  11.  
  12. console.log("from es6b");
  13. ```
  14.  
  15. ```js
  16. // cjsa.js
  17.  
  18. const a = require("es6a.js");
  19. const b = require("es6b.js");
  20. ```
  21.  
  22. - If it takes less than 10 milliseconds to retrieve es6b.js from disk, this will evaluate es6a.js, y.js, es6b.js
  23. - If it takes more than 10 milliseconds to retrieve es6b.js, this will evaluate es6a.js, es6b.js, y.js.
  24.  
  25. In contrast, with promises (or with equivalent ES6 imports):
  26.  
  27. ```js
  28. // cjsb.js
  29.  
  30. (async () => {
  31. const a = await require("es6a.js");
  32. const b = await require("es6b.js");
  33. })
  34. .catch(console.error);
  35. ```
  36.  
  37. Evaluation order will always be es6a.js, y.js, es6b.js.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement