Skip to content

Commit f04629b

Browse files
authored
Enhance README with clearer usage instructions
Updated README to clarify usage and improve examples.
1 parent 0100779 commit f04629b

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

README.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,18 @@
66

77
# Rebol/Zstd
88

9-
[Zstandard](https://github.com/facebook/zstd) extension for [Rebol3](https://github.com/Oldes/Rebol3) (version 3.20.5 and higher)
9+
[Zstandard](https://github.com/facebook/zstd) compression extension for [Rebol3](https://github.com/Oldes/Rebol3) (version 3.20.5 or newer)
1010

11-
## Usage
12-
Basic usage is just using `import zstd` and then use `zstd` method with default Rebol `compress` and `decompress` functions. Like:
11+
## Basic usage
12+
Use Zstandard as a codec for the standard compress and decompress functions:
1313
```rebol
1414
import zstd
1515
bin: compress "some data" 'zstd
1616
txt: to string! decompress bin 'zstd
1717
```
1818

19-
Additionally, this extension provides a streaming API, allowing data to be (de)compressed in chunks without requiring it to be fully loaded into memory.
19+
## Streaming API
20+
The streaming API lets you process data in chunks, which is useful for large inputs, pipes, or network streams.
2021
```rebol
2122
zstd: import zstd ;; Import the module and assign it to a variable
2223
enc: zstd/make-encoder ;; Initialize the Zstandard encoder state handle
@@ -29,6 +30,7 @@ bin1: zstd/read :enc
2930
;; Continue with other data and use `/finish` to encode all remaining input
3031
;; and mark the stream as complete.
3132
bin2: zstd/write/finish :enc " from Rebol!"
33+
3234
;; Decompress both compressed blocks again (using extension's command this time):
3335
text: to string! zstd/decompress join bin1 bin2
3436
;== "Hello Zstandard from Rebol!"
@@ -41,14 +43,13 @@ text: to string! zstd/read :dec ;; Resolve decompressed data
4143
;== "Hello Zstandard from Rebol!"
4244
```
4345

44-
Using this streaming API, you can write functions like these:
46+
### Example: file helpers
47+
These (basic) examples show how to build file-level utilities on top of the streaming API.
4548
```rebol
4649
compress-file: function[file][
4750
src: open/read file ;; input file
48-
out: open/new/write join file %.br ;; output file
51+
out: open/new/write join file %.zst ;; output file
4952
enc: zstd/make-encoder/level 6 ;; initialize Zstandard encoder
50-
enc/size-hint: size? src
51-
enc/mode: 1 ;= text input
5253
chunk-size: 65536
5354
while [not finish][
5455
chunk: copy/part src chunk-size

0 commit comments

Comments
 (0)