One common convention in scripting languages like JS is to export private functions publicly, but prefix their names with an underscore to denote that they should not be considered part of the public interface.
Although this convention is widely followed, without a way to enforce privacy, consumers of the module may end up ignoring the convention and using the function anyway.
In order to enforce that private functions that are exported publicly can’t be used by consumers of the module, we use an environment variable that denotes whether the code is being required for tests.
Your new post is loading...