Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ```js
- // es6a.js
- await foo(); // takes 10 milliseconds
- require('./y.js');
- ```
- ```js
- // es6b.js
- console.log("from es6b");
- ```
- ```js
- // cjsa.js
- const a = require("es6a.js");
- const b = require("es6b.js");
- ```
- - If it takes less than 10 milliseconds to retrieve es6b.js from disk, this will evaluate es6a.js, y.js, es6b.js
- - If it takes more than 10 milliseconds to retrieve es6b.js, this will evaluate es6a.js, es6b.js, y.js.
- In contrast, with promises (or with equivalent ES6 imports):
- ```js
- // cjsb.js
- (async () => {
- const a = await require("es6a.js");
- const b = await require("es6b.js");
- })
- .catch(console.error);
- ```
- Evaluation order will always be es6a.js, y.js, es6b.js.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement