-
I have observed the following pattern being used in many places in the codebase: let varToReferAModule;
// Other code
// Inside of a function
if(!varToReferAModule) varToReferAModule = require('path/to/that/module'); What's the benefit of using this pattern instead of simply using: let varToReferAModule = require('path/to/that/module'); wherever Exampleslet eos;
// Other code
if (!eos) eos = require('internal/streams/end-of-stream');
|
Beta Was this translation helpful? Give feedback.
Answered by
devsnek
Oct 21, 2020
Replies: 1 comment
-
We use it to lazily load functionality, so that Node.js can start faster. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
ugultopu
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We use it to lazily load functionality, so that Node.js can start faster.