First of all:
Thank you, thank you, thank you! AWESOME. Period.
There is one thing I do not know: How to parse the binary data
back to a StructType?
/** EXAMPLE */
var reified = require('reified');
var fs = require('fs');
// define type Message
var Message = reified('Message', {
id: reified('Uint32'),
hash: reified('Uint8')
});
// create a message
var message = new Message({
id: Math.floor(Math.random()*10000000),
hash: Math.floor(Math.random()*128)
});
console.log(message); // Message { id: Uint32 4194906 | hash: Uint8 73 }
// write the buffer to a file
fs.writeFileSync('reified-test.dat', message.buffer);
// load the file
var buffer = fs.readFileSync('reified-test.dat');
// recreate
var message = new Message(buffer);
console.log(message); // Message { id: Uint32 0 | hash: Uint8 0 }
/** EXAMPLE END */
Message { id: Uint32 0 | hash: Uint8 0 }
not what was saved.
I tried .fill, .write, or even
new Message(Array.prototype.slice(buffer,0))
.. nothing worked.
So, how to do it? How to get that buffer into the Struct?
And again: Thank you.
On Thu, Mar 22, 2012 at 1:36 AM, Brandon Benvie
<[email protected]> wrote:
> For some reason I spaced out and forgot that DataViews and ArrayBuffers work
> perfectly well with node Buffers and so I implemented a kind of useless
> parallel buffer API. I'm putting the finishing touches on a combined one
> that uses those in both and it's looking a lot better. It's not really
> impactful on the rest of the library too much because there's only actually
> 2 or 3 points in the code where a buffer write or read method is called. But
> it'll help with implementing some other things I have planned like better
> string support.
>
>
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
--
Oliver Leics @ G+
https://plus.google.com/112912441146721682527
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en