sindresorhus/awesome-nodejs

[Suggestion] ref-libraries

Closed this issue · 4 comments

mifi commented

TooTallNate's ref-libraries are awesome when you need to parse or generate structured binary data. For instance data coming from kernel space, based on structs and C-types from header files.
Not sure how to categorize them here.

https://github.com/TooTallNate/ref
https://github.com/TooTallNate/ref-struct
https://github.com/TooTallNate/ref-array
https://github.com/TooTallNate/ref-union

Docs:
http://tootallnate.github.io/ref/

Sure. I think it's enough to link to ref though. Can you do a pull request?

Just curious. How would you use ref to interact with header files? I'm very noob at this. Is this meant to be used with an FFI module?

mifi commented

You can't directly interact with .h-files, but you can make equivalents of c data structures and pointers in javascript. It can be useful when you want to parse/generate data according to a proprietary binary protocol, maybe over the network or through ioctl-calls. In my case I am trying to make a node module for parsing OSX's com.apple.network.statistics ioctl response.
fs.read method returns a Buffer which can be described by structs defined here:
http://opensource.apple.com/source/xnu/xnu-3247.10.11/bsd/net/ntstat.h

ref is actually being used by node-ffi too :)

Which category should I put it under? Parsing? Misc?

Parsing

mifi commented

See #582