1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

compress: add a new module compress.gzip too (#14686)

This commit is contained in:
Leo Developer
2022-06-05 17:53:45 +02:00
committed by GitHub
parent 7b25957a26
commit 3a90d8ef14
8 changed files with 277 additions and 13 deletions

View File

@@ -3,9 +3,6 @@
`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:

View File

@@ -2,15 +2,14 @@ module deflate
import compress
// compresses an array of bytes using gzip and returns the compressed bytes in a new array
// Example: compressed := gzip.compress(b)?
// compresses an array of bytes using deflate and returns the compressed bytes in a new array
// Example: compressed := deflate.compress(b)?
pub fn compress(data []u8) ?[]u8 {
return compress.compress(data, 0)
}
// decompresses an array of bytes using zlib and returns the decompressed bytes in a new array
// Example: decompressed := zlib.decompress(b)?
[manualfree]
// decompresses an array of bytes using deflate and returns the decompressed bytes in a new array
// Example: decompressed := deflate.decompress(b)?
pub fn decompress(data []u8) ?[]u8 {
return compress.decompress(data, 0)
}