lib/polyfill/v2_4/enumerator/lazy.rb in polyfill-0.6.0 vs lib/polyfill/v2_4/enumerator/lazy.rb in polyfill-0.7.0
- old
+ new
@@ -1,11 +1,23 @@
-require_relative 'lazy/instance'
-
module Polyfill
module V2_4
module Enumerator
module Lazy
- include Instance
+ 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