which-module
Find the module object for something that was require()d
Find the module
object in require.cache
for something that was require()
d or import
ed - essentially a reverse require()
lookup.
Useful for libs that want to e.g. lookup a filename for a module or submodule that it did not require()
itself.
Install and Usage
API
whichModule(exported)
whichModule(exported)
Return the module
object, if any, that represents the given argument in the require.cache
.
exported
can be anything that was previously require()
d or import
ed as a module, submodule, or dependency - which means exported
is identical to the module.exports
returned by this method.
If exported
did not come from the exports
of a module
in require.cache
, then this method returns null
.
License
ISC © Contributors
Last updated