compress.gzip / deflate: rename gzip module into deflate module (#14682)
parent
4cf6abd99d
commit
b000728845
|
@ -1,4 +1,4 @@
|
|||
## Description:
|
||||
|
||||
`compress` is a namespace for (multiple) compression algorithms supported by V.
|
||||
At the moment, only `compress.zlib` and `compress.gzip` are implemented.
|
||||
At the moment, only `compress.zlib` and `compress.deflate` are implemented.
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
## Description:
|
||||
|
||||
`compress.deflate` is a module that assists in the compression and
|
||||
decompression of binary data using `deflate` compression
|
||||
|
||||
NOTE: To decompress gzip, discard first 10 bytes of compressed bytes
|
||||
then use `compress.deflate.decompress`. (Header validation won't be
|
||||
performed in this case)
|
||||
|
||||
## Examples:
|
||||
|
||||
```v
|
||||
import compress.deflate
|
||||
|
||||
fn main() {
|
||||
uncompressed := 'Hello world!'
|
||||
compressed := deflate.compress(uncompressed.bytes())?
|
||||
decompressed := deflate.decompress(compressed)?
|
||||
assert decompressed == uncompressed.bytes()
|
||||
}
|
||||
```
|
|
@ -1,4 +1,4 @@
|
|||
module gzip
|
||||
module deflate
|
||||
|
||||
import compress
|
||||
|
|
@ -1,8 +1,12 @@
|
|||
module gzip
|
||||
module deflate
|
||||
|
||||
const gzip_magic_numbers = [u8(0x1f), 0x8b]
|
||||
|
||||
fn test_gzip() ? {
|
||||
uncompressed := 'Hello world!'
|
||||
compressed := compress(uncompressed.bytes())?
|
||||
first2 := compressed[0..2]
|
||||
assert first2 != deflate.gzip_magic_numbers
|
||||
decompressed := decompress(compressed)?
|
||||
assert decompressed == uncompressed.bytes()
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
## Description:
|
||||
|
||||
`compress.gzip` is a module that assists in the compression and
|
||||
decompression of binary data using `gzip` compression
|
||||
|
||||
## Examples:
|
||||
|
||||
```v
|
||||
import compress.gzip
|
||||
|
||||
fn main() {
|
||||
uncompressed := 'Hello world!'
|
||||
compressed := gzip.compress(uncompressed.bytes())?
|
||||
decompressed := gzip.decompress(compressed)?
|
||||
assert decompressed == uncompressed.bytes()
|
||||
}
|
||||
```
|
Loading…
Reference in New Issue