Answer the question
In order to leave comments, you need to log in
How to add the rest of the bytes to the buffer?
I create a buffer for two bytes, only one is written, how can I fill the last byte with 00?
This option is not suitable because bl.length can be any length and 0 and 1 and 2
Wrote like this, but how terrible it is)
Buffer.alloc(2).write( String( bl.length ) )
Buffer.concat([Buffer.from([]), Buffer.alloc(2)])
Buffer.concat([ Buffer.from([bl.length]), Buffer.alloc(2 - Buffer.from([bl.length]).length ) ])
Answer the question
In order to leave comments, you need to log in
There are two functions for this
https://nodejs.org/api/buffer.html#buffer_buf_writ...
https://nodejs.org/api/buffer.html#buffer_buf_writ...
Same for reading only if BE write - do not read LE;)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question