asyncAwait2.js 759 B

1234567891011121314151617181920212223
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. function resolveWait(x) {
  6. return new Promise(resolve => {
  7. WScript.SetTimeout(() => {
  8. resolve(x);
  9. }, 100);
  10. });
  11. }
  12. async function awaitImm(x) {
  13. const a = await resolveWait(1);
  14. const b = await resolveWait(2);
  15. return x + a + b;
  16. }
  17. awaitImm(1).then(v => {
  18. telemetryLog(v.toString(), true);
  19. emitTTDLog(ttdLogURI);
  20. });