Nodejs module interface design issues?

  node.js, question

Please click here
This module only exposes one interfacecreate(factory function). At that time, when designing the interface, we did not consider too much and directly referred to a similar module.
Now think back and return to the constructorIDCardOCRIt seems that it can also be done.

However, there seems to be a difference: constructors can access methods on the prototype chain, while factory functions cannot.
So, will there be any bad consequences if the constructor is returned? What are the other differences?
Thank you

Are you sure you are right about the “difference”?

YourscreateAccess is to call the constructor new to create an instance, so the returned results can of course also access methods on the prototype chain. why not?

Returning a constructor does not have any “bad” consequences, which depend on the user. A small advantage of not returning a constructor is to avoid users forgetting new, because javascript does not have static checks, and sometimes forgetting new can lead to unexpected consequences. However, this is also a matter of habit.