Sha256: e992fd6bbc8694d4e49a4c39bbd67ac6d34ad66e3d18eb074c0eacf32fe14d9c
Contents?: true
Size: 852 Bytes
Versions: 5
Compression:
Stored size: 852 Bytes
Contents
module Kernel def promise(p = Promise.new, &block) begin result = block.call return p.resolve(result) if result after(10) { promise(p, &block) } rescue => e return p.reject(e) end p end if RUBY_ENGINE == 'opal' def on_browser?; true; end def on_desktop?; false; end def on_mobile?; false; end def on_tablet?; false; end def on_tv?; false; end def on_server?; false; end def after(time_ms, &block) `setTimeout(#{block.to_n}, time_ms)` end else def on_browser?; false; end def on_desktop?; false; end def on_mobile?; false; end def on_tablet?; false; end def on_tv?; false; end def on_server?; true; end def after(time_ms, &block) sleep time_ms/1000 block.call end end end
Version data entries
5 entries across 5 versions & 1 rubygems