Jsi has ArrayBuffer but TurboModules doesn't? #157
shamilovtim
started this conversation in
Deep Dive
Replies: 2 comments 1 reply
-
Following up on this: I see that ArrayBuffer is available from |
Beta Was this translation helpful? Give feedback.
1 reply
-
I have the same issue, I want to compress / decompress data (uint8_t *). This seems like a lot of boilerplate code just to convert the result. - (NSArray *)compress:(NSString *)buffIn compressionLevel:(double)compressionLevel {
unsigned int compressedSizeOut = 0;
const char* _buffIn = [buffIn UTF8String];
uint8_t *compressedData = rnzstd::compress(_buffIn, compressionLevel, compressedSizeOut);
NSMutableArray *array = [NSMutableArray arrayWithCapacity:compressedSizeOut];
for (NSUInteger i = 0; i < compressedSizeOut; i++) {
[array addObject:[NSNumber numberWithUnsignedChar:compressedData[i]]];
}
NSArray *compressedArr = [NSArray arrayWithArray:array];
delete[] compressedData;
return compressedArr;
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Update on this thread: I see that ArrayBuffer is available from
JSI
. Is there a reason it's omitted from TurboModules and NativeModules?I run into the issue multiple times per year when I work with binary where I need to convert between different types on each platform in a wasteful manner going in and out of different conversion types. This is because the original conversion methods never had binary, only the following:
I would have expected something like NSData to bind to UInt8Array, Buffer, ArrayBuffer or Blob but I'm not sure I understand why it doesn't exist and if this is some misunderstanding on my part. In the past I think I sent it across the bridge as base64 strings, which seems bad and unnecessary. Now with the New Architecture, it seems that binding JS binary to NSData (or equivalent Android) should be pretty straightforward. Should RN have it as one of the shared Native <-> JS types. It seems like it would be pretty trivial to implement if under the hood it's all the same JSI / JNI shared objects. Am I missing anything?
Beta Was this translation helpful? Give feedback.
All reactions