Sha256: ccf3053d61508fbdc887d684b77afadc70128040620f209fd0374f1ebaa3c5bf

Contents?: true

Size: 541 Bytes

Versions: 10

Compression:

Stored size: 541 Bytes

Contents

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

10 entries across 10 versions & 1 rubygems

Version Path
opal-1.7.4 opal/corelib/enumerator/yielder.rb
opal-1.7.3 opal/corelib/enumerator/yielder.rb
opal-1.7.2 opal/corelib/enumerator/yielder.rb
opal-1.7.1 opal/corelib/enumerator/yielder.rb
opal-1.7.0 opal/corelib/enumerator/yielder.rb
opal-1.7.0.rc1 opal/corelib/enumerator/yielder.rb
opal-1.6.1 opal/corelib/enumerator/yielder.rb
opal-1.6.0 opal/corelib/enumerator/yielder.rb
opal-1.6.0.rc1 opal/corelib/enumerator/yielder.rb
opal-1.6.0.alpha1 opal/corelib/enumerator/yielder.rb