We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
--module
Executing the following script with the --module option produces strange results.
Screenshot of running results:
The script (test-async-sleep.js):
test-async-sleep.js
(async () => { if (globalThis.setTimeout === undefined) { console.log("Trying to import 'os' module"); const os = await import('os'); globalThis.setTimeout = os.setTimeout; console.log(`globalThis.setTimeout = ${globalThis.setTimeout}`); } const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms)); async function gen(ident, count, delay) { var curr, cost; var last = Date.now(); var i, total = 0; for (i = 0; i < count; ++i) { await sleep(delay); curr = Date.now(); cost = curr - last; last = curr; total += cost; console.log(`${ident}: ${i}, curr = ${curr}, cost = ${cost}`); } return total / count; } var g1 = gen(1, 1, 100); var g2 = gen(2, 2, 100); var g3 = gen(3, 2, 100); c1 = await g1; // c2 = await g2; // c3 = await g3; console.log(`averageCost = ${c1}`); // console.log(`averageCost = ${c2}`); g2.then((cost) => { console.log(`averageCost = ${cost}`); }); g3.then((cost) => { console.log(`averageCost = ${cost}`); }); })();
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Executing the following script with the
--module
option produces strange results.Screenshot of running results:
![image](https://private-user-images.githubusercontent.com/32818900/334067277-3fab4901-415b-49ef-93dc-1211a3d15f9f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjExODUwNTQsIm5iZiI6MTcyMTE4NDc1NCwicGF0aCI6Ii8zMjgxODkwMC8zMzQwNjcyNzctM2ZhYjQ5MDEtNDE1Yi00OWVmLTkzZGMtMTIxMWEzZDE1ZjlmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MTclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzE3VDAyNTIzNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTJjZTA4YjhhYmYzNTM3NDhlNjc5YTZjYTJhNzU4NzQ1NDYxOWEzMmQxODc2Yjg4ZTM1ZmNkNDhjMWNjNTFjZTUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.36rnafazZl8mcjEUiuyqfiHg03Z00w_-pNyqikcF9p4)
The script (
test-async-sleep.js
):The text was updated successfully, but these errors were encountered: