timeout.js 508 B

123456789101112131415161718
  1. /*
  2. Copyright 2019 Google LLC
  3. Use of this source code is governed by an MIT-style
  4. license that can be found in the LICENSE file or at
  5. https://opensource.org/licenses/MIT.
  6. */
  7. import '../_version.js';
  8. /**
  9. * Returns a promise that resolves and the passed number of milliseconds.
  10. * This utility is an async/await-friendly version of `setTimeout`.
  11. *
  12. * @param {number} ms
  13. * @return {Promise}
  14. * @private
  15. */
  16. export function timeout(ms) {
  17. return new Promise((resolve) => setTimeout(resolve, ms));
  18. }