How to use opencv extra modules?

In node modules, should I use closures or use their private variables?

  • I am programming for prototypal inheritance, and thus will be extending other modules (also my own). I thus plan to write a normal object with all public methods and variables in it, and then have the module.exports constructor return a copy of it. I am wondering if I should encapsulate private variables inside of the returned object using closure-based getters and setters or simply keep them out of the object entirely and instead in the entire module space, which is designated to be private?

  • Answer:

    Module.exports is just an object, not necessarily a constructor. It's personal preference. Keeping variables in the module's scope will make things much cleaner.

Brian Chu at Quora Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.