A React Native library for accessing an ArrayBuffer of a Blob instance.

Overview

react-native-blob-jsi-helper

Try Showtime!

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

npm install react-native-blob-jsi-helper

Usage

Accessing the ArrayBuffer of a Blob instance

import { getArrayBufferForBlob } from "react-native-blob-jsi-helper";

// ...

const blob = ...
const arrayBuffer = getArrayBufferForBlob(blob);

Creating a Blob from an ArrayBuffer

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 to learn how to contribute to the repository and the development workflow.

License

MIT

Comments
  • [Android] Wrong arraybuffer is generated

    [Android] Wrong arraybuffer is generated

    Hi,

    I am using pdf-lib (https://github.com/Hopding/pdf-lib) to manage pdf on my rn app

    pdf-lib takes an arraybuffer as param, for the moment I convert my local pdf files as base64 and then to arraybuffer (using https://github.com/beatgammit/base64-js) to use them as params in pdf-lib methods

    I wanted to try your lib to check if I could have better perfs. Unfortunately generated arraybuffer with react-native-blob-jsi-helper cannot be used with pdf-lib. I have made a small project to check the diff between using react-native-blob-jsi-helper and using base64 : https://github.com/mlecoq/jsi-blob-issue

    When I log the generated buffer with react-native-blob-jsi-helper, first values seem correct but then I only have zeros:

    [37, 80, 68, 70, 45, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ....
    

    compared to correct arraybuffer

    [37, 80, 68, 70, 45, 49, 46, 51, 13, 10, 37, 226, 227, 207, 211, 13, 10, 13, 10, 49, 32, 48, 32, 111, 98, 106, 13, 10, 60, 60, 13, 10, 47, 84, 121, 112, 101, 32, 47, 67, 97, 116, 97, 108, 111, 103, 13, 10, 47, 79, 117, 116, 108, 105, 110, 101, 115, 32, 50, 32, 48, 32, 82, 13, 10, 47, 80, 97, 103, 101, 115, 32, 51, 32, 48, 32, 82, 13, 10, 62, 62, 13, 10, 101, 110, 100, 111, 98, 106, 13, 10, 13, 10, 50, 32, 48, 32, 111, 98, 106, 13, 10, 60, 60, 13, 10, 47, 84, 121, 112, 101, 32, 47, 79, 117, 116, 108, 105, 110, 101, 115, 13, 10, 47, 67, 111, 117, 110, 116, 32, 48, 13, 10, 62, 62, 13, 10, 101, 110, 100, 111, 98, 106, 13, 10, 13, 10, 51, 32, 48, 32, 111, 98, 106, 13, 10, 60, 60, 13, 10, 47, 84, 121, 112, 101, 32, 47, 80, 97, 103, 101, 115, 13, 10, 47, 67, ...
    
    opened by mlecoq 10
  • Value is undefined, expected an object

    Value is undefined, expected an object

    Hi,

    during my development I have a strange issue after hot reloading (on Android - with hermes) on calling getArrayBufferForBlob:

    Value is undefined, expected an object

    I have to restart metro after any code change

    opened by mlecoq 3
  • react native 0.69 build issue

    react native 0.69 build issue

    Hi, with react native 0.69, I have a build issue

    * Where:
    Build file '/Users/mlecoq/Developer/archireport/archireport-mobile/node_modules/react-native-blob-jsi-helper/android/build.gradle' line: 165
    
    * What went wrong:
    A problem occurred evaluating project ':react-native-blob-jsi-helper'.
    > Expected directory '/Users/mlecoq/Developer/archireport/archireport-mobile/node_modules/react-native/android' to contain exactly one file, however, it contains more than one file.
    

    I solved it modifying build.gradle following line:

     def rnAAR = fileTree("${defaultDir.toString()}").matching({ it.include "**/**/*.aar" }).singleFile
    

    with

     def rnAAR = fileTree("${defaultDir.toString()}").matching({ it.include "**/**/react-native*-release.aar" }).singleFile
    

    but it's not backward compatible with RN 0.68

    opened by mlecoq 2
  • fix: #7 rn 0.69 android build issue

    fix: #7 rn 0.69 android build issue

    This PR is a copy of https://github.com/mrousavy/react-native-mmkv/pull/414 to fix #7 which is the same issue as https://github.com/mrousavy/react-native-mmkv/issues/412

    opened by mlecoq 1
  • Logs

    Logs

    https://github.com/mrousavy/react-native-blob-jsi-helper/blob/06d95e5da32fec124e2c7e10cbc282b628ba8e26/src/index.tsx#L42

    Will this be stripped automatically when building or a leftover?

    opened by hirbod 1
  • Can't not build ios when use_framework is enabled

    Can't not build ios when use_framework is enabled

    Hi, here is error log from xcode, this is block me using this library. Hope you can take a look on this. Thanks so much

    Undefined symbol: facebook::jsi::JSError::JSError(facebook::jsi::Runtime&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >)
    
    Undefined symbol: facebook::jsi::JSError::~JSError()
    
    Undefined symbol: facebook::jsi::Value::asObject(facebook::jsi::Runtime&) &&
    
    Undefined symbol: _OBJC_CLASS_$_RCTBlobManager
    
    Undefined symbol: facebook::jsi::Value::asObject(facebook::jsi::Runtime&) const &
    
    opened by iamvucms 0
Releases(v0.2.3)
Owner
Marc Rousavy
they call me ranch cause i be dressing
Marc Rousavy
A contacts library for React Native using JSI

react-native-jsi-contacts The current react-native-contacts library uses the React Native Bridge to convert the native Java/Objective-C types to JavaS

Marc Rousavy 139 Sep 7, 2022
A fast base64 module for React Native

react-native-quick-base64 A native implementation of Base64 in C++ for React Native. 4x faster than base64-js on an iPhone 11 Pro.

Takuya Matsuyama 209 Sep 26, 2022
A framework for building native Windows apps with React.

React Native for Windows Build native Windows apps with React. See the official React Native website for an introduction to React Native. React Native

Microsoft 15k Oct 3, 2022
React-Native build of Hyperswarm and dependencies

Testing Hyperbeam Start hyperbeam on your computer and copy-paste address to packages/mobile/App.tsx. Then in another terminal run yarn mobile:start a

Tomas Ravinskas 5 Sep 5, 2022
React Native polyfill for crypto.getRandomValues. Used in libraries like uuid.

react-native-random-values-jsi-helper React Native polyfill for crypto.getRandomValues. Used in libraries like uuid. Installation yarn add react-nativ

Matei Oprea 30 Sep 8, 2022
A step by step example of creating your own React Native TurboModule.

Discovering Turbo Modules Note: This example was made in RN 0.63. Some things have changed since then, but the good news is that now the setup should

Bartłomiej Klocek 90 Sep 20, 2022
Libguestfs is tools and a library for accessing and modifying guest disk images

Libguestfs is tools and a library for accessing and modifying guest disk images

null 506 Oct 1, 2022
Two PoC of accessing process virtual memory via NT Kernel

ProcessVmAccess Two PoC of accessing process virtual memory via NT Kernel Detail You've never interested in accessing process virtual memory through N

Kento Oki 16 Aug 11, 2022
This is where I store my CS homework in BUPT. Also synced with my own gitea instance

BUPT-Homework Introduction This is my repository for the BUPT-Homework project. Structure Root directory: semesters problem sets solutions to the prob

JuanCC 2 Jan 9, 2022
C++React: A reactive programming library for C++11.

C++React is reactive programming library for C++14. It enables the declarative definition of data dependencies between state and event flows. Based on

Sebastian 953 Sep 17, 2022
Plays native alert sound and shows native dialogs/alerts in your Flutter app.

flutter_platform_alert 2021 © Weizhong Yang a.k.a zonble. A simple plugin to present native alerts, including playing alert sounds and showing alert d

Weizhong Yang a.k.a zonble 57 Sep 27, 2022
Visual Studio native debugger extension to help debug native applications using Mono.

Unity Mixed Callstack UnityMixedCallstack is a Visual Studio 2017/2019 extension to help debug native applications embedding Mono, like Unity. If you

Unity Technologies 79 Sep 30, 2022
Projeto pessoal: Obter a temperatura ambiente e através de um termistor ligado a um arduino e disponibilizar esses dados em tempo real via API NodeJS. No front-end os dados são acessados por uma interface em React JS.

INTEGRAÇÃO DA API COM OS DADOS DO ARDUINO FORNECIDOS PELO TERMISTOR Código Desenvolvido por Lucas Muffato. MATERIAIS 1 Placa de Arduino; 1 Cabo de con

Lucas Muffato 35 Aug 16, 2022
A simple library that helps Android developers to execute JavaScript code from Android native side easily without using Webview.

AndroidJSModule A simple library that helps Android developers to execute JavaScript code from Android native side easily without using Webview. Insta

Hung Nguyen 5 May 24, 2022
A Native Binary Emulator Library and Utility

binmulator A Native Binary Emulator Library and Utility Most emulators for malware detection are written in Python and fail when certain emulated API

c3rb3ru5 3 Jun 27, 2022
It's a static library that's provide a way to do hooking (intercepting software components) in native shared object from some Android Packages

ARM_hook It's a static library that's provide a way to do hooking (intercepting software components) in native shared object from some Android Package

Gabriel Correia 1 Feb 17, 2022
A Dart package to send native 💬 toasts on Windows. Based on WinToast.

desktoasts A Dart package to send native ?? toasts on Windows. Installation For Flutter dependencies: ... desktoasts: ^0.0.2 For Dart CLI here Sup

Hitesh Kumar Saini 37 Mar 7, 2022
Haxe native extension to read and write windows clipboard.

Haxe Clipboard This is a native library to read and write clipboard data from Haxe. It uses Ammer to generate bindings. Note: This is a Windows only l

Ludovic Bas 10 Feb 25, 2022
Jimp-native is a fast C++ re-implementation of Jimp with zero system dependencies and minimal overhead!

Jimp native Make your sever-side Jimp code run 10x faster! Jimp-native is a fast C++ re-implementation of Jimp with zero system dependencies and minim

Sjoerd 16 Sep 24, 2022