Skip to content

f-meloni/SwiftBrotli

Repository files navigation

SwiftBrotli

Swift 5.1 Carthage compatible

A lightweight Swift wrapper for Google's brotli

What is Brotli?

Brotli is a generic-purpose lossless compression algorithm that compresses data using a combination of a modern variant of the LZ77 algorithm, Huffman coding and 2nd order context modeling, with a compression ratio comparable to the best currently available general-purpose compression methods. It is similar in speed with deflate but offers more dense compression.

The specification of the Brotli Compressed Data Format is defined in RFC 7932.

Why use Brotli?

Brotli uses a dictionary of common keywords and phrases on both client and server side and thus gives a better compression ratio for text data.

Articles and comparisons:

Usage

Compress data

let brotli = Brotli()
brotli.compress(data)

Decompress data

let brotli = Brotli()
brotli.decompress(data)

Encode JSON object

let encoder = BrotliJSONEncoder()
encoder.encode(object)

Decode JSON object

let decoder = BrotliJSONDecoder()
let result: Result<Object, Error> = decoder.decode(data)

About

A lightweight Swift wrapper for Google's Brotli

Resources

License

Stars

Watchers

Forks

Packages

No packages published