I want to generate some binary data in my Node.js application and then write it in an HTTP response to be downloaded by the client. My current implementation of the same application is in Python , which achieves this using struct. For instance,
import struct
# ...
s = 'Filename header'
s_binary = struct.pack('15s',s)
# ...
Also, how to convert numbers to binary files in Node.js? How I do it in Python:
import struct
num_binary = struct.pack('f',23.33)
How do I do the same in Node.js?
This is the best solution I have - the direct port of the Python struct library for Node.js is jspack .
source
share