Comments (1)
Hmm, I am not sure about this.
As far as I understand you would like to have the following function added (as an example, I use Deflate here, but this also applies to other components):
extension Deflate {
public static func decompress<Result>(data: Data, _ callback: ((???) -> Result)? = nil) throws -> Data {
/* ... */
}
}
The key question here is what should be the input type of the callback? What value should decompression function pass to the callback function to indicate the progress? Off the top of my head, I can think of two options, both vaguely defined:
- Some numerical value indicating how many "internal structures" (blocks, frames, streams, etc.) from the input data has been processed so far. However, in many cases it is impossible to tell ahead of time without processing the entire input, how many of these structures you have in total, and without that this progress value is even more meaningless.
- How many bytes of the input have been processed so far. While this is better defined, there is another problem: how often/at what points during the decompression should the callback function be called. Depending on the answer to this question, you may end up with callback function being called too often, which in turn will slow down the decompression even more.
Finally, I should point out that the phrase "show that everything is okay" is also hard to define, because in practice everything is okay by default, and if something is not, an error is thrown. In view of this, I personally think that the callback function is a bit redundant.
from swcompression.
Related Issues (20)
- [CRASH] LittleEndianByteReader.swift:33:20 HOT 2
- Memory issues when working with larger files HOT 8
- [CRASH] MsbBitReader.bit() HOT 4
- AR Format Support HOT 7
- Can Gzip unarchive return Member? HOT 1
- GzipArchive.unarchive wrongMagic for short data HOT 1
- Brotli Support? HOT 2
- Symlinks in tarballs are created with absolute paths HOT 3
- BZip2Error.wrongCRC when decompressing HOT 2
- Support File I/O for large archives and resource-constrained environments
- Error when decompressing a certain 7z file HOT 2
- Some zip files can't be extracted HOT 2
- LZ4 format not compatible? HOT 8
- Compiling for watchOS fails HOT 1
- LZ4 decompress speed HOT 10
- Support splitting zips into multiple files
- Is there a way to extract a single file from a 7z compressed archive? HOT 4
- LZFSE Support
- Please update BitByteData dependency HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swcompression.