|
19 | 19 | // can be created using NODE_MODULE_CONTEXT_AWARE_CPP() with the flag
|
20 | 20 | // NM_F_LINKED.
|
21 | 21 | // - internalBinding(): the private internal C++ binding loader, inaccessible
|
22 |
| -// from user land because they are only available from NativeModule.require() |
| 22 | +// from user land because they are only available from NativeModule.require(). |
23 | 23 | // These C++ bindings are created using NODE_MODULE_CONTEXT_AWARE_INTERNAL()
|
24 | 24 | // and have their nm_flags set to NM_F_INTERNAL.
|
25 | 25 | //
|
|
61 | 61 | keys: ObjectKeys,
|
62 | 62 | } = Object;
|
63 | 63 |
|
64 |
| - // Set up process.moduleLoadList |
| 64 | + // Set up process.moduleLoadList. |
65 | 65 | const moduleLoadList = [];
|
66 | 66 | ObjectDefineProperty(process, 'moduleLoadList', {
|
67 | 67 | value: moduleLoadList,
|
|
70 | 70 | writable: false
|
71 | 71 | });
|
72 | 72 |
|
73 |
| - // Set up process.binding() and process._linkedBinding() |
| 73 | + // Set up process.binding() and process._linkedBinding(). |
74 | 74 | {
|
75 | 75 | const bindingObj = ObjectCreate(null);
|
76 | 76 |
|
|
93 | 93 | };
|
94 | 94 | }
|
95 | 95 |
|
96 |
| - // Set up internalBinding() in the closure |
| 96 | + // Set up internalBinding() in the closure. |
97 | 97 | let internalBinding;
|
98 | 98 | {
|
99 | 99 | const bindingObj = ObjectCreate(null);
|
|
115 | 115 | };
|
116 | 116 | }
|
117 | 117 |
|
118 |
| - // Create this WeakMap in js-land because V8 has no C++ API for WeakMap |
| 118 | + // Create this WeakMap in js-land because V8 has no C++ API for WeakMap. |
119 | 119 | internalBinding('module_wrap').callbackMap = new WeakMap();
|
120 | 120 | const { ContextifyScript } = process.binding('contextify');
|
121 | 121 |
|
122 |
| - // Set up NativeModule |
| 122 | + // Set up NativeModule. |
123 | 123 | function NativeModule(id) {
|
124 | 124 | this.filename = `${id}.js`;
|
125 | 125 | this.id = id;
|
|
128 | 128 | this.exportKeys = undefined;
|
129 | 129 | this.loaded = false;
|
130 | 130 | this.loading = false;
|
131 |
| - this.script = null; // The ContextifyScript of the module |
| 131 | + this.script = null; // The ContextifyScript of the module. |
132 | 132 | }
|
133 | 133 |
|
134 | 134 | NativeModule._source = getBinding('natives');
|
|
160 | 160 | if (!NativeModule.exists(id)) {
|
161 | 161 | // Model the error off the internal/errors.js model, but
|
162 | 162 | // do not use that module given that it could actually be
|
163 |
| - // the one causing the error if there's a bug in Node.js |
| 163 | + // the one causing the error if there's a bug in Node.js. |
164 | 164 | // eslint-disable-next-line no-restricted-syntax
|
165 | 165 | const err = new Error(`No such built-in module: ${id}`);
|
166 | 166 | err.code = 'ERR_UNKNOWN_BUILTIN_MODULE';
|
|
201 | 201 |
|
202 | 202 | if (config.exposeInternals) {
|
203 | 203 | NativeModule.nonInternalExists = function(id) {
|
204 |
| - // Do not expose this to user land even with --expose-internals |
| 204 | + // Do not expose this to user land even with --expose-internals. |
205 | 205 | if (id === loaderId) {
|
206 | 206 | return false;
|
207 | 207 | }
|
208 | 208 | return NativeModule.exists(id);
|
209 | 209 | };
|
210 | 210 |
|
211 | 211 | NativeModule.isInternal = function(id) {
|
212 |
| - // Do not expose this to user land even with --expose-internals |
| 212 | + // Do not expose this to user land even with --expose-internals. |
213 | 213 | return id === loaderId;
|
214 | 214 | };
|
215 | 215 | } else {
|
|
243 | 243 | };
|
244 | 244 |
|
245 | 245 | // Provide named exports for all builtin libraries so that the libraries
|
246 |
| - // may be imported in a nicer way for esm users. The default export is left |
| 246 | + // may be imported in a nicer way for ESM users. The default export is left |
247 | 247 | // as the entire namespace (module.exports) and wrapped in a proxy such
|
248 | 248 | // that APMs and other behavior are still left intact.
|
249 | 249 | NativeModule.prototype.proxifyExports = function() {
|
|
0 commit comments