
Pure DEFLATE, GZIP and ZLIB compression/decompression with blocking and streaming APIs, configurable levels, preset-dictionary support, and high-performance parity with standard implementations.
Pure Kotlin Multiplatform DEFLATE, GZIP, and ZLIB compression.
KFlate is a Kotlin Multiplatform port of the npm fflate library. It provides compression and decompression with configurable levels, dictionary support, and both blocking and streaming APIs.
Current version 1.0.0.
KFlate delivers performance comparable to standard implementations across all platforms:
For detailed benchmark results, see the performance/ folder.
dependencies {
implementation("com.rafambn:KFlate:1.0.0")
}import com.rafambn.kflate.KFlate
import com.rafambn.kflate.RAW
import com.rafambn.kflate.Raw
val input = "hello".encodeToByteArray()
val deflated = KFlate.compress(input, RAW())
val inflated = KFlate.decompress(deflated, Raw())import com.rafambn.kflate.KFlate
import com.rafambn.kflate.GZIP
import com.rafambn.kflate.Gzip
val input = "hello".encodeToByteArray()
val options = GZIP(
filename = "hello.txt",
comment = "example",
extraFields = mapOf("AB" to byteArrayOf(1, 2)),
includeHeaderCrc = true
)
val gz = KFlate.compress(input, options)
val roundTrip = KFlate.decompress(gz, Gzip())import com.rafambn.kflate.KFlate
import com.rafambn.kflate.ZLIB
import com.rafambn.kflate.Zlib
val input = "hello".encodeToByteArray()
val z = KFlate.compress(input, ZLIB())
val out = KFlate.decompress(z, Zlib())
// With a preset dictionary
val dict = "common".encodeToByteArray()
val options = ZLIB(dictionary = dict)
val zWithDict = KFlate.compress(input, options)level: Compression level 0–9 (default: 6)
bufferSize: Internal hash table size (optional, auto-sized per level)dictionary: Preset dictionary up to 32 KB (DEFLATE/ZLIB only)filename: Original filenamecomment: File commentextraFields: Custom header fieldsmtime: Modification timeincludeHeaderCrc: Include CRC16 of headerdictionary: Preset dictionary for DEFLATE/ZLIB (required if compression used one)Pure Kotlin Multiplatform DEFLATE, GZIP, and ZLIB compression.
KFlate is a Kotlin Multiplatform port of the npm fflate library. It provides compression and decompression with configurable levels, dictionary support, and both blocking and streaming APIs.
Current version 1.0.0.
KFlate delivers performance comparable to standard implementations across all platforms:
For detailed benchmark results, see the performance/ folder.
dependencies {
implementation("com.rafambn:KFlate:1.0.0")
}import com.rafambn.kflate.KFlate
import com.rafambn.kflate.RAW
import com.rafambn.kflate.Raw
val input = "hello".encodeToByteArray()
val deflated = KFlate.compress(input, RAW())
val inflated = KFlate.decompress(deflated, Raw())import com.rafambn.kflate.KFlate
import com.rafambn.kflate.GZIP
import com.rafambn.kflate.Gzip
val input = "hello".encodeToByteArray()
val options = GZIP(
filename = "hello.txt",
comment = "example",
extraFields = mapOf("AB" to byteArrayOf(1, 2)),
includeHeaderCrc = true
)
val gz = KFlate.compress(input, options)
val roundTrip = KFlate.decompress(gz, Gzip())import com.rafambn.kflate.KFlate
import com.rafambn.kflate.ZLIB
import com.rafambn.kflate.Zlib
val input = "hello".encodeToByteArray()
val z = KFlate.compress(input, ZLIB())
val out = KFlate.decompress(z, Zlib())
// With a preset dictionary
val dict = "common".encodeToByteArray()
val options = ZLIB(dictionary = dict)
val zWithDict = KFlate.compress(input, options)level: Compression level 0–9 (default: 6)
bufferSize: Internal hash table size (optional, auto-sized per level)dictionary: Preset dictionary up to 32 KB (DEFLATE/ZLIB only)filename: Original filenamecomment: File commentextraFields: Custom header fieldsmtime: Modification timeincludeHeaderCrc: Include CRC16 of headerdictionary: Preset dictionary for DEFLATE/ZLIB (required if compression used one)