DroidsOnRoids/SwiftCompressor

Name: SwiftCompressor

Owner: Droids On Roids

Description: SwiftCompressor lets you use Compression framework easily

Created: 2016-02-24 12:01:05.0

Updated: 2018-04-12 05:20:41.0

Pushed: 2016-09-26 08:48:15.0

Homepage: http://www.thedroidsonroids.com/

Size: 64

Language: Shell

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

SwiftCompressor

CI Status codecov Version License Platform

Requirements

iOS 9.0+, macOS 10.11+, watchOS 2.0+, tvOS 9.0+

Swift 3

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

SwiftCompressor is available through CocoaPods. To install it, simply add the following line to your Podfile:

"SwiftCompressor"
Usage

SwiftCompression is a Data extension. It lets you easily compress/decompress Data objects this way:

reate NSData from file
path = URL(fileURLWithPath: Bundle.main.path(forResource: "lorem", ofType: "txt")!)
loremData = try? Data(contentsOf: path)

ompress and then decompress it!
compressedData = try? loremData?.compress()
decompressedData = try? compressedData??.decompress()

ou can also choose one of four algorithms and set a buffer size if you want.
vailable algorithms are LZFSE, LZMA, ZLIB and LZ4.
ompression without parameters uses LZFSE algorithm. Default buffer size is 4096 bytes.
compressWithLZ4 = try? loremData?.compress(algorithm: .lz4)
compressWithLZMAReallyBigBuffer = try? loremData?.compress(algorithm: .lzma, bufferSize: 65_536)
Author

Piotr Sochalewski, piotr.sochalewski@droidsonroids.com

License

SwiftCompressor is available under the MIT license. See the LICENSE file for more info.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.