I'm interested in making my first native C/C++ addon for nodeJS.
Conceptually it's a filesystem method that acts on a path or a file descriptor and is closely related to fs.stat()
and friends.
From reading the documentation and looking at N-API examples I can't see whether it's possible or definitely impossible to create a new method.
Does anybody know if this can be done or if I have to just make it standalone?
I think the only way to do this is to "wrap" the object you want to extend.
Basically make a new module "fs2" that passes through all the standard calls to "fs" that is
require
d by your new module, but also add your new calls, or replace the calls you wish to augment, with your N-API calls.Code using your module would then only need to use
instead of
I'm not sure if there are several ways to wrap a nodeJS module to achieve this, or if there is one clearly best way. I'm sure there are other SO questions covering all that.