Well, I found the best answer (Ivan Škugor), and I want to put it here to share with anyone who has the same question. Thank you for your help.
“Extending your own prototypes is not a good idea at all. In this particular case, this should not be a big problem in some other environments, but using CommonJs is a problem because every CommonJs module is a new JS context, which means a pure JS environment. So, everything that you do with the environment (for example, extending your own prototypes) will not be reflected in other modules. Because of this, it is best to write a "utils" module with auxiliary functions and "require" it anywhere. "
//utils.js exports.trim = function(str) { return str.replace(/^\s+|\s+$/g,""); };
- Ivan Škugor
junior
source share