Sha256: c1a811a3cc447c7abeb88b77768c61a6367c013bbb17a09bf01a102872546bf0

Contents?: true

Size: 454 Bytes

Versions: 6

Compression:

Stored size: 454 Bytes

Contents

module Polyfill
  module V2_4
    module Enumerator
      module Lazy
        using Polyfill(Enumerable: %w[#chunk_while])

        def chunk_while
          super.lazy
        end

        def uniq
          seen = Set.new

          ::Enumerator::Lazy.new(self) do |yielder, *values|
            result = block_given? ? yield(*values) : values

            yielder.<<(*values) if seen.add?(result)
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
polyfill-1.0.1 lib/polyfill/v2_4/enumerator/lazy.rb
polyfill-1.0.0 lib/polyfill/v2_4/enumerator/lazy.rb
polyfill-0.10.0 lib/polyfill/v2_4/enumerator/lazy.rb
polyfill-0.9.0 lib/polyfill/v2_4/enumerator/lazy.rb
polyfill-0.8.0 lib/polyfill/v2_4/enumerator/lazy.rb
polyfill-0.7.0 lib/polyfill/v2_4/enumerator/lazy.rb