core.delay.js 406 B

123456789101112
  1. var global = require('./_global');
  2. var core = require('./_core');
  3. var $export = require('./_export');
  4. var partial = require('./_partial');
  5. // https://esdiscuss.org/topic/promise-returning-delay-function
  6. $export($export.G + $export.F, {
  7. delay: function delay(time) {
  8. return new (core.Promise || global.Promise)(function (resolve) {
  9. setTimeout(partial.call(resolve, true), time);
  10. });
  11. }
  12. });