Growling from Node … or why is Array.pack missing from Javascript?

Since it came out I’ve been really interessed in Node. So I decided to do something with it, and to get me started I hacked together a little module to allow me to do what every good programming environment should allow: Sent me some Growl notifications :D…

Nodejs growl.png

This involved some rather low level UDP packet construction, but for now it works. Maybe somebody will find it useful, I put the code up on Github.

While writing the module I realized I was missing one piece coming from network coding using ruby, Array.pack(format) why is this missing? Is there an alternative? How do I turn an Array into a buffer following some custom format? Well for now I solved this by a little hacked function extending Array, this is neither clean nor well tested but it works for me while looking for a way to this right. For anyone interested here it is, and don’t kill me cause it’s ugly

https://gist.github.com/734947.js

Enjoy.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s