Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mrousavy/react-native-blob-jsi-helper
A React Native library for accessing an ArrayBuffer of a Blob instance.
https://github.com/mrousavy/react-native-blob-jsi-helper
Last synced: 4 days ago
JSON representation
A React Native library for accessing an ArrayBuffer of a Blob instance.
- Host: GitHub
- URL: https://github.com/mrousavy/react-native-blob-jsi-helper
- Owner: mrousavy
- License: mit
- Created: 2022-01-18T11:19:51.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2023-07-07T08:26:46.000Z (over 1 year ago)
- Last Synced: 2024-05-02T00:59:20.395Z (7 months ago)
- Language: C++
- Size: 607 KB
- Stars: 119
- Watchers: 7
- Forks: 7
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# react-native-blob-jsi-helper
[![Try Showtime!](./img/github-banner.png)](http://showtime.io)
A React Native library for directly accessing an ArrayBuffer of a Blob instance.
> Note: This is a workaround. A long-term solution would be to implement this directly on the Blob instance in React Native Core.
## Installation
```sh
npm install react-native-blob-jsi-helper
```## Usage
### Accessing the ArrayBuffer of a Blob instance
```js
import { getArrayBufferForBlob } from "react-native-blob-jsi-helper";// ...
const blob = ...
const arrayBuffer = getArrayBufferForBlob(blob);
```### Creating a Blob from an ArrayBuffer
```js
import { getBlobForArrayBuffer } from "react-native-blob-jsi-helper";// ...
const arrayBuffer = ...
const blob = getBlobForArrayBuffer(arrayBuffer);
```## Performance
If you know me, you know that my libraries are as fast as they can get. react-native-blob-jsi-helper is no different - it is written in C++ JSI and is therefore really fast.
* **Zero** bridge-traffic.
* **Zero** serialization/deserialization.### Blob -> ArrayBuffer
* For a **10 kB** Buffer, I have measured **1ms**.
* For a **12 MB** Buffer, I have measured **13ms**.### ArrayBuffer -> Blob
* For a **10 kB** Buffer, I have measured **0.05ms**.
* For a **12 MB** Buffer, I have measured **0.3ms**.## Contributing
See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
## License
MIT