Sha256: a0e2aa3598f11b82fa6482a88aca4778cd1d82a3e42e4cfddcffaa04afe01701

Contents?: true

Size: 380 Bytes

Versions: 1

Compression:

Stored size: 380 Bytes

Contents

# frozen_string_literal: true

module Pull
  class Map
    def initialize(&block)
      @block = block
    end

    def call(read)
      -> (finish, callback) {
        if finish
          on_abort.()
          return nil
        end

        read.(nil, -> (value) {
          callback.(block.call(value))
        })
      }
    end

    private

    attr_reader :block
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pull_stream-1.0.0 lib/pull/through/map.rb