Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,20 @@ require 'zstd-ruby' # Add the appropriate require statement if necessary
io = StringIO.new(compressed_data)
reader = Zstd::StreamReader.new(io)

# Read and output the decompressed data
puts reader.read(10) # 'abc'
puts reader.read(10) # 'def'
puts reader.read(10) # '' (end of data)
# read(n) returns up to n decompressed bytes, or nil at the end of the stream.
puts reader.read(10).inspect # "abc"
puts reader.read(10).inspect # nil (end of data)
```

`eof?` reports whether the stream has been fully consumed:

```ruby
io = StringIO.new(compressed_data)
reader = Zstd::StreamReader.new(io)

reader.eof? # => false
reader.read(10) # => "abc"
reader.eof? # => true
```


Expand Down
Loading