I have a Node.js library file that is required by my Node.js application file, exporting a function.
In the application file I am calling the exported function, passing it some parameters, and it is working fine.
In one of the parameters, I would like to send the name of a function that is declared in the application file; this is so that the parameters can be JSONified. However, the code in the library file cannot find the function by name, because it exists in another file (the application one).
I know I can get over this by passing a pointer to the function, instead of its name, but because of serialization (functions cannot be serialized), I would like to pass the name.
I cannot just export the function from the application file and import it in the library file because that would be a circular reference, and, of course, the library file does not need to know about the application one.
What is the recommended pattern for dealing with this kind of situations?