The Compression
Kit.
To use this package in a SwiftPM project, you need to set it up as a package dependency:
// swift-tools-version:5.4
import PackageDescription
let package = Package(
name: "MyPackage",
dependencies: [
.package(
url: "https://github.com/L1MeN9Yu/Elva.git", from: "2.0.0" // or `.upToNextMajor
)
],
targets: [
.target(
name: "MyTarget",
dependencies: [
.product(name: "ZSTD", package: "Elva"),// ZSTD
.product(name: "Brotli", package: "Elva"),// Brotli
.product(name: "LZ4", package: "Elva"),// LZ4
]
)
]
)
zstd Swift wrapper.
- Compress
import ZSTD
let compressConfig = ZSTD.CompressConfig.default
let data = Data()
let inputMemory = BufferedMemoryStream(startData: data)
let compressMemory = BufferedMemoryStream()
try ZSTD.compress(reader: inputMemory, writer: compressMemory, config: compressConfig)
let compressedData = compressMemory.representation
- Decompress
import ZSTD
let decompressConfig = ZSTD.DecompressConfig.default
let data = ...
let inputMemory = BufferedMemoryStream(startData: data)
let decompressMemory = BufferedMemoryStream()
try ZSTD.decompress(reader: inputMemory, writer: decompressMemory, config: compressConfig)
let decompressedData = decompressMemory.representation
brotli Swift wrapper.
- Compress
import Brotli
let compressConfig = Brotli.CompressConfig.default
let data = Data()
let inputMemory = BufferedMemoryStream(startData: data)
let compressMemory = BufferedMemoryStream()
try Brotli.compress(reader: inputMemory, writer: compressMemory, config: compressConfig)
let compressedData = compressMemory.representation
- Decompress
import Brotli
let decompressConfig = Brotli.DecompressConfig.default
let data = ...
let inputMemory = BufferedMemoryStream(startData: data)
let decompressMemory = BufferedMemoryStream()
try Brotli.decompress(reader: inputMemory, writer: decompressMemory, config: compressConfig)
let decompressedData = decompressMemory.representation
LZ4 Swift wrapper.
- Compress
import LZ4
let compressConfig = LZ4.CompressConfig.default
let data = Data()
let inputMemory = BufferedMemoryStream(startData: data)
let compressMemory = BufferedMemoryStream()
try LZ4.compress(reader: inputMemory, writer: compressMemory, config: compressConfig)
let compressedData = compressMemory.representation
- Decompress
import LZ4
let decompressConfig = LZ4.DecompressConfig.default
let data = ...
let inputMemory = BufferedMemoryStream(startData: data)
let decompressMemory = BufferedMemoryStream()
try LZ4.decompress(reader: inputMemory, writer: decompressMemory, config: compressConfig)
let decompressedData = decompressMemory.representation
brew bundle
to installpre-commit
,swiftformat
,swiftlint
pre-commit install
to install git hook.
Thanks to JetBrains for "Licenses for Open Source Development". JetBrains supports non-commercial open source projects by providing core project contributors with a set of best-in-class developer tools free of charge.
感谢 JetBrains 提供的开源开发许可证。JetBrains 通过为项目核心开发者免费提供开发工具来支持非商业开源项目。