Line data Source code
1 : // Licensed under the Apache License, Version 2.0
2 : // Copyright 2025, Michael Bushe, All rights reserved.
3 :
4 : import 'dart:io';
5 : import 'dart:typed_data';
6 :
7 : /// The [GZip] encodes raw bytes to GZip compressed bytes and decodes GZip
8 : /// compressed bytes to raw bytes.
9 : ///
10 : /// It is implemented using `dart:io` on native platforms and platform-specific
11 : /// implementations in browsers.
12 : class GZip {
13 : /// Compress the [data] using gzip compression.
14 1 : Future<List<int>> compress(Uint8List data) async =>
15 2 : gzip.encoder.convert(data);
16 :
17 : /// Decode the gzip-compressed [data].
18 1 : Future<List<int>> decompress(Uint8List data) async =>
19 2 : gzip.decoder.convert(data);
20 : }
|