compress.gzip / deflate: rename gzip module into deflate module (#14682)

master
ChAoS_UnItY 2022-06-05 13:48:38 +08:00 committed by GitHub
parent 4cf6abd99d
commit b000728845
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 28 additions and 20 deletions

View File

@ -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.

View File

@ -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()
}
```

View File

@ -1,4 +1,4 @@
module gzip
module deflate
import compress

View File

@ -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()
}

View File

@ -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()
}
```