The nodejs Buffer
is pretty swell. However, it seems to be geared towards storing strings. The constructors either take a string, an array of bytes, or a size of bytes to allocate.
I am using version 0.4.12 of Node.js, and I want to store an integer in a buffer. Not integer.toString()
, but the actual bytes of the integer. Is there an easy way to do this without looping over the integer and doing some bit-twiddling? I could do that, but I feel like this is a problem someone else must have faced at some time.