node-struct
node-struct copied to clipboard
How do I use the same template to read different buffers?
I am using struct to write the header of binary files. If the struct template is Header, is it ok to do:
Header.allocate(); var data1=Header.buffer();
fill data1 with my settings, and then do again
Header.allocate(); var data2=Header.buffer();
to create file number 2?
There is no sense to call allocate twice on same instance. Reuse old buffer, create new instance, or use _setBuffer method