168 questions
2
votes
2
answers
153
views
Type narrowing of Uint8Array<ArrayBufferLike> to Uint8Array<ArrayBuffer>
Since TypeScript 5.9 we have (roughly speaking) Uint8Array = Uint8Array<ArrayBufferLike> = Uint8Array<ArrayBuffer | SharedArrayBuffer>. Now I am looking for a clean and idiomatic way to ...
0
votes
1
answer
109
views
Fastest way to convert BigInt to Uint8Array?
Situation:
A JSON object that has an array of ~3000 elements. Each element is in format
base64String.base64String.base64String.base64String....
Somewhere around 20-30 base64String separated with ..
...
1
vote
0
answers
120
views
JS Postal-Mime with binary attachment
I am using the NPM package postal-mime to process inbound emails through cloudflare workers. Similar code to on this guide.
https://docs.emailengine.app/how-to-parse-emails-with-cloudflare-email-...
0
votes
0
answers
284
views
How to convert Float32Array PCM data into Uint8Array?
I have a AudioBuffer from AudioContext, and I get Float32Array from AudioBuffer.getChannelData,It's in range -1 to 1, and I dont know how to convert the data into Uint8Array, then I can encode it into ...
0
votes
4
answers
853
views
How to url-encode UInt8Array in JavaScript?
How can I urlencode a UInt8Array in JavaScript? using encodeURIComponent does not work, for example with
encodeURIComponent((new Uint8Array([72,101,108,108,111,32,87,111,114,108,100])));
I expected:
...
1
vote
1
answer
2k
views
Displaying a pdf in a new browser tab from a Uint8Array
Background
I'm generating a PDF file dynamically in the backend of my web app using pdf-lib. Then, I send the PDF bytes in the form of Uint8Array to frontend in order to open a new tab that will ...
0
votes
1
answer
989
views
why does a Uint8Array() from buffer returns empty?
I am trying to load a font for pdf-lib to use. In order to use it, i must provide a Uint8Array for pdfDoc.embedFont(font);
For some reason, whenever i create the UInt8Array, it returns empty. The ...
-3
votes
2
answers
836
views
Pass uint8_t* as parameter to raw function pointer
I have the problem where I want to pass a uint8_t[] array as a parameter to a function pointer defined as `typedef void (dangerousC)(void); Also, I'm using Windows API headers.
Assume the variable raw ...
0
votes
0
answers
286
views
Deno convert bmp image file data into a Uint8Array
I am currently trying to load a .bmp image file with Deno and then convert the data of the image into a black/white Uint8Array.
I load the image using:
const imageFile = await Deno.readFile('./path/to/...
0
votes
0
answers
414
views
uint8_t element assignment to uint8_t array in C++
I am trying to create a uint8_t array and try to change the first element of the array, then print it to the terminal as a string.
But, after I assign currBlock (changed block) to arr[0], cout gives ...
0
votes
1
answer
643
views
How do I convert a List<dynamic> into a viewable image in Flutter?
sample.json is a file containing a list of values from 0 to 100 under a header called "readings":
[
{
"id": 105399,
"time": "2022-11-22 01:25:23....
1
vote
0
answers
250
views
Polkadot.js sr25519 secret key to hex
I am creation a keypair using sr25519PairFromSeed.
I am converting the public key from Uint8Array to hex using encodeAddress(publicKey, 0),
but i have issues converting the secret key from Uint8array ...
1
vote
0
answers
150
views
What causes byteOffset to be non-zero with Node fs.readFileSync?
We have some data we're reading with code like:
const readData = fs.readFileSync('./dummy')
And readData then looks like below, with a byteOffset of 4664
We then need to make a buffer from that ...
1
vote
2
answers
81
views
Construct chess board like texture with Uint8Array
Code:
var options = {
squareShema: [8,8],
pixels: new Uint8Array(8 * 8 * 4)
};
options.pixels.fill(122);
var I = 0, localCounter = 0;
// options.pixels.fill(I ,funny, funny+1);
for (...
0
votes
0
answers
697
views
Android BLE get raw values from onCharacteristicChanged
Is there a way to get the characteristic.value in onCharacteristicChanged as a byteArray of size 64 in binary?
I successfully subscribe to a notify-characteristic of a BLE Service (in Android/Kotlin). ...
3
votes
1
answer
2k
views
How to convert async AsyncIterable<Uint8Array> to File in Javascript
Hello I'm sending/POST a File from a HTML Form on a browser client to a Remix application server.
The Remix applicaton server is sending/handling my File as a async AsyncIterable.
I now need to ...
1
vote
1
answer
748
views
How to get an array of strings based on Uint8Array values (map Uint8 values to String/s)
new Uint8Array([1,2,3]).map((v,y)=>"0"+v+"0"+y)
> Uint8Array(3) [ 100, 201, 46 ] // actual
> ["0100","0201","0302"] // expected
new ...
0
votes
1
answer
693
views
javascript: from a websocket I receive messages as zlib deflate: how to read OR "unflate" OR "deflate" (not inflate)
This question is about converting a gzip deflate message from a websocket message and convert it to array OR raw text that I can apply JSON.parse on it...
*** to be also clear: In this question : i ...
0
votes
1
answer
412
views
read CAR file using js-car
I have a CAR file object in javascript and want to read it using js-car github. But I keep getting unexpected end of the file error. Here is my code I am trying
let arrayBuffer = await files[0]....
6
votes
4
answers
8k
views
How to convert a Javascript number to a Uint8Array?
I have a Javascript integer (whose precision can go up to 2^53 - 1), and I am trying to send it over the wire using an ArrayBuffer. I suppose I could use BigInt64Array, but the browser support still ...
0
votes
1
answer
9k
views
The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array. Received type number - When using Uint8Array.slice()
My code implementation is the following extension of the Uint8Array class.
export class ByteArray extends Uint8Array {
...
private _encoded: string;
...
constructor(_encoded: string)...
1
vote
1
answer
881
views
Saving a numpy array in binary does not improve disk usage compared to uint8
I'm saving numpy arrays while trying to use as little disk space as possible.
Along the way I realized that saving a boolean numpy array does not improve disk usage compared to a uint8 array.
Is there ...
2
votes
1
answer
7k
views
SOLANA sendAndConfirmTransaction and sendTransaction ERROR ( unexpected type, use Uint8Array)
It has been a real big issue finding solution to the error on Solana Transaction API
I have sent several messages to the tech discord group and the Telegram group and still did not find any of the ...
1
vote
2
answers
2k
views
ROS2: how to create an Int8MultiArray
This is a ROS2 beginner question
I've tried to use several ROS sources which suggested me to include "std_msgs/Int8MultiArray.h".
However, if I do that I will get an error that is
fatal ...
2
votes
1
answer
1k
views
Decoding Variant bytes from Godot to javascript object
I'm trying to deserialize a byte array which I believe is a Uint8 array from Godot into a javascript object in a node process.
My current implementation is :
const message = Buffer.from(buffer.data, '...