Sha256: 13fb539552a00afe06abe4c9d951c23fe884651b35fe499eea5427ceebab1b97
Contents?: true
Size: 573 Bytes
Versions: 8
Compression:
Stored size: 573 Bytes
Contents
require 'promise' module Kernel def exit(status = true) status = 0 if `status === true` # it's in JS because it can be null/undef $__at_exit__ ||= [] process_promises = nil exit_block = -> { `Opal.exit(status)`; nil } next_at_exit = -> do if $__at_exit__.size > 0 block = $__at_exit__.pop result = block.call result.is_a?(Promise) ? result.then(&next_at_exit) : next_at_exit.call else result.is_a?(Promise) ? result.then(&exit_block) : exit_block.call end end next_at_exit.call end end
Version data entries
8 entries across 8 versions & 1 rubygems