Giter Site home page Giter Site logo

swiftzstd's Introduction

SwiftZSTD

Swift Package Manager Mac + Linux

Description

Swift Wrapper around Zstandard Compression Library

System Requirements

Zstandard is required to be installed in order to build this package. See https://github.com/facebook/zstd for additional information, including licensing.

On OS X the easiest way to install Zstandard is with homebrew

brew install zstd

On Ubuntu it can be installed with apt

sudo apt install libzstd-dev

Installation

This has been bundled as a swift package for Swift 5. To use it in a project include the pacakge as a dependency in your projects Package.swift:

    dependencies: [
        .package(url: "https://github.com/HeartedApp/SwiftZSTD", .branch("master"))
    ],

In order to test out the included example ZSTDSampleApp run swift run

$ swift run
Testing compression

Original size: 1465 bytes
Compressed size: 757 bytes
Decompressed string is the same as original.

Testing compression with dictionary

Building Dictionary
Original size: 1465 bytes
Compressed size: 438 bytes
Dictionary decompressed string is the same as original.

Limitations

Compression and de-compression of in-memory buffers is supported, with or without a context or a dictionary. Buffers are represented by Data instances that must use contiguous storage, and in practice most Data instances meet this requirement. To be decompressed by this code, a buffer must be a complete frame with decompressed size encoded in it and retrievable using ZSTD_getDecompressedSize().

This is actually a fairly useful implementation. Experimentation shows that even fairly large files (100s of MB),when compressed using the zstd utility provided with the C library, end up in a single frame, which is easily decompressible by this Swift code if read into memory as one piece.

swiftzstd's People

Contributors

aperedera avatar heartedapp avatar omniprog avatar

Stargazers

Swift Studies avatar  avatar

Forkers

palaeowiggles

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.