Skip to content

Commit

Permalink
add NewReader function (#85)
Browse files Browse the repository at this point in the history
Co-authored-by: Youenn Laborde <[email protected]>
  • Loading branch information
kahlys and Youenn Laborde authored Oct 23, 2020
1 parent 7e5288d commit c121f44
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions progressbar.go
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,14 @@ type Reader struct {
bar *ProgressBar
}

// NewReader return a new Reader with a given progress bar.
func NewReader(r io.Reader, bar *ProgressBar) Reader {
return Reader{
Reader: r,
bar: bar,
}
}

// Read will read the data and add the number of bytes to the progressbar
func (r *Reader) Read(p []byte) (n int, err error) {
n, err = r.Reader.Read(p)
Expand Down

0 comments on commit c121f44

Please sign in to comment.