164
rated 0 times
[
166]
[
2]
/ answers: 1 / hits: 19701
/ 7 Years ago, mon, august 21, 2017, 12:00:00
I'm using Node.js
to gzip some files and output their raw byte array to a file.
For example:
test.txt:
1234
text.txt > test.txt.gz
test.txt.gz to byte array > array.txt
array.txt:
{0x66,0x75,0x6e,0x63,0x74,0x69,0x6f,0x6e}
I couldn't seem to find any other questions on converting files to byte-arrays, or any npm packages. I have attempted to manually fs.readFileSync
a file and use it in a function, but due to the special characters and encoding it failed.
How can I convert a file to a byte array in Node.js natively or using a package?
More From » arrays