core.delay.js 406 B

12345678910111213
  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. });