This is not possible in node without more advanced reflection tools such as a debugger.
The only way to do this is to use __parent__
, which has been removed due to security issues and more. As Mark Bessie said, when you run the script, these variables become module closing variables. You cannot access them elsewhere without exporting them explicitly.
This is not a mistake, it is by design. This is how node works. However, if you just ask your users to write a function expression assignment, everyone will work a-ok:
module.exports = { a:function(){
Then you can easily flip and list modules.exports and get all the function names.
source share