171
edits
m (Added environment.args and require.entry.) |
(Renamed require.entry to require.main to be a bit more familiar.) |
||
Line 5: | Line 5: | ||
* id: the "require" object MAY have an "id" member that must be the normalized identifier of the current module | * id: the "require" object MAY have an "id" member that must be the normalized identifier of the current module | ||
* loader: the "require" object MAY have a "loader" member that is an interface to the object used by "require" to acquire module factory functions. Tampering with this variable must not alter the behavior of "require". | * loader: the "require" object MAY have a "loader" member that is an interface to the object used by "require" to acquire module factory functions. Tampering with this variable must not alter the behavior of "require". | ||
* | * main: the "require" object MAY have an "main" member that is the module ID of the module that was the entry point for this sandbox. Thus the common Python idiom <tt>if __name__ == '__main__':</tt> would be <tt>if (require.id == require.main)</tt>, except that this strategy avoids the problem of double loading the main module if it's referred to elsewhere by its real name. | ||
edits