Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mateoguzmana/react-native-lz4
LZ4 – C++ React Native bindings for an extremely fast compression algorithm.
https://github.com/mateoguzmana/react-native-lz4
android compression ios lz4 react-native zip
Last synced: about 2 months ago
JSON representation
LZ4 – C++ React Native bindings for an extremely fast compression algorithm.
- Host: GitHub
- URL: https://github.com/mateoguzmana/react-native-lz4
- Owner: mateoguzmana
- License: mit
- Created: 2024-09-25T21:57:06.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-10-12T23:29:05.000Z (3 months ago)
- Last Synced: 2024-11-01T06:51:28.741Z (2 months ago)
- Topics: android, compression, ios, lz4, react-native, zip
- Language: TypeScript
- Homepage:
- Size: 2.81 MB
- Stars: 9
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# react-native-lz4
LZ4 – React Native bindings for an extremely fast compression algorithm.
Compress and decompress files using the LZ4 algorithm in React Native. This library binds the [LZ4 C library](https://github.com/lz4/lz4) to React Native via C++ TurboModules.
The library could also be extended to support other LZ4 features if needed.
## Installation
```sh
npm i react-native-lz4
cd ios && pod install
```## Usage
```ts
import { compressFile, decompressFile } from 'react-native-lz4';function onProgress(processedSize: number, totalSize: number) {
// e.g. { processedSize: 50, totalSize: 100, progress: '50%' }
console.log({
processedSize,
totalSize,
progress: `${Math.round((processedSize / totalSize) * 100)}%`,
});
}const compressionResult = await compressFile(
'path/to/file',
'path/to/output',
onProgress
);
const decompressionResult = await decompressFile(
'path/to/file',
'path/to/output',
onProgress
);console.log(compressionResult);
// { success: true, message: 'File compressed successfully', originalSize: 100, finalSize: 50 }console.log(decompressionResult);
// { success: true, message: 'File decompressed successfully', originalSize: 50, finalSize: 100 }
```See the [example](example) for a full working example.
## Contributing
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
## License
MIT