Sha256: 9dc42b00f789765de111f3a82e5ad90502fb39e830be9c2a7d09e17e70237034

Contents?: true

Size: 570 Bytes

Versions: 6

Compression:

Stored size: 570 Bytes

Contents

# backtick_javascript: true

class Enumerator
  class Yielder
    def initialize(&block)
      @block = block
      # rubocop:disable Lint/Void
      self
      # rubocop:enable Lint/Void
    end

    def yield(*values)
      %x{
        var value = Opal.yieldX(#{@block}, values);

        if (value && value.$thrower_type == "break") {
          throw value;
        }

        return value;
      }
    end

    def <<(value)
      self.yield(value)

      self
    end

    def to_proc
      proc do |*values|
        self.yield(*values)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
opal-1.8.3.rc1 opal/corelib/enumerator/yielder.rb
opal-1.8.2 opal/corelib/enumerator/yielder.rb
opal-1.8.1 opal/corelib/enumerator/yielder.rb
opal-1.8.0 opal/corelib/enumerator/yielder.rb
opal-1.8.0.beta1 opal/corelib/enumerator/yielder.rb
opal-1.8.0.alpha1 opal/corelib/enumerator/yielder.rb