You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 16, 2019. It is now read-only.
With recent support in RN for TypedArray's, is there a way (or planned support) for writing them directly, instead of base64 strings or normal arrays? For example, I tried something simple like:
const fs = RNFetchBlob.fs
const dirs = RNFetchBlob.fs.dirs
let path = dirs.DocumentDir + '/test.txt'
let arr = new Uint8Array(10)
fs.writeFile(path, arr, 'ascii')
.then(() => console.log("Wrote data to: " + path))
And this results in an Error: Expected "data" is an Array when encoding is "ascii", however got object. For now, I'm working around the issue by converting to a normal array like this:
However, I'm thinking there's some performance overhead to this, as it's creating a shallow copy of the entire array (not as bad as Base64 encoding I guess). Would it make sense to add support for RFNB to accept TypedArray's directly?
The text was updated successfully, but these errors were encountered:
Not sure if I'm misunderstanding what TypedArray support in RN means, but I was going off this WebKit bug report and facebook/react-native#1424. With a fresh RN 0.48.4 project, I'm able to declare and populate UInt8Array's OK. I thought in older RN versions the TypedArray variants weren't present?
We are trying to keep issues focused on bugs and this is more of a feature request,
So, no, there is no support yet. Please reopen when there is, I'll be the first one to implement the Android side, albeit for the fs functions only (I don't touch the fetch code) since we need it ourselves.
With recent support in RN for TypedArray's, is there a way (or planned support) for writing them directly, instead of base64 strings or normal arrays? For example, I tried something simple like:
And this results in an
Error: Expected "data" is an Array when encoding is "ascii", however got object
. For now, I'm working around the issue by converting to a normal array like this:However, I'm thinking there's some performance overhead to this, as it's creating a shallow copy of the entire array (not as bad as Base64 encoding I guess). Would it make sense to add support for RFNB to accept TypedArray's directly?
The text was updated successfully, but these errors were encountered: