The node documentation for addons is self-admittedly pretty weak as of v0.4.0.
This chapter doesn’t aim to be a replacement for the official documentation. Instead, we’d hope this can expand on some of the basics a little more than a simple “Hello, World!” and drive you as a developer more on the path toward mastering node through its source code.
In fact, for now, we’re only going to cover some shortcuts for creating properties on an object, functions, and interacting with function prototypes. This doesn’t reach the evented level of node’s awesomeness, but you should be able to look at examples in node’s source and the documention for libev and libeio to find answers.
Pre-requisites
Some C/C++ knowledge
V8 JavaScript
Internal Node libraries
libeio
hello.node
Our first example is the very same one from node’s docs. We’re going to include it for those who haven’t read through the docs and have instead trusted in the knowledge of this ebook’s authors (thanks, by the way).
A node addon begins with a source file containing a single entry point:
... ➦