No built-ins (yet - might be a worthwhile addition). Buffer objects
have (undocumented) utility methods to write out integers and floats:
https://github.com/joyent/node/blob/02699a3/lib/buffer.js#L747
I'm on the fence (but would support a well-written, well-tested
pack/unpack implementation). The bare essentials are already there and
most people that need a fast protocol parser drop to C++ anyway.
@nodejs-dev: binary pack / unpack in core - good idea, bad idea? I say good.
Well, JSON is in the core (actually, it's in v8), is supported nearly
everywhere and can be used for serializing stuff. If you need better
compression or so, you can always use a specialized module (part of
nodes philosphy is a small core library with many good modules around
it):
http://search.npmjs.org/
For example, there are things like msgpack and dht-bencode.
Jann
I think it would be good to have an extensible pack implementation that allows templating. I don't think this is something that should be in core though (we generally want people to be able to avoid using binary data manipulation with this complexity I would think). That being said, I would avoid string based formatting as it is hard to extend (though fast to dev and somewhat readable) in whatever module provides this, having that on top of an extensible module is much easier than the other way around.
https://github.com/joyent/node/wiki/node-core-vs-userland
If someone wants to implement a good api for this, and support it, and
it rises to fairly universal acceptance within the community, and it
follows node's coding guidelines, and it is well tested and
documented, and Ryan et al feel that it's something that fits nicely
with the other network-programming utilities in node, then it can
always be pulled into core.
On the other hand, if it's awesome, and in npm, then you might not
actually need it to be in core anyhow. The Node Way is that it should
be *really hard* to justify putting something into node core, and
*really easy* to publish them in userland.
> --
> You received this message because you are subscribed to the Google Groups "nodejs" group.
> To post to this group, send email to nod...@googlegroups.com.
> To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/nodejs?hl=en.
>
>
http://bigeasy.github.com/node-packet/
This should do what you want. Under development, but the packing and
unpacking noted above is implemented.
--
Alan Gutierrez - http://twitter.com/bigeasy - http://github.com/bigeasy