mirror of
https://github.com/nodejs/node.git
synced 2025-08-15 13:48:44 +02:00
doc: correct customization hook types & clarify descriptions
PR-URL: https://github.com/nodejs/node/pull/56454 Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit is contained in:
parent
5770972dc6
commit
fc11189cbd
2 changed files with 37 additions and 11 deletions
|
@ -25,17 +25,40 @@ let debug = require('internal/util/debuglog').debuglog('module_hooks', (fn) => {
|
|||
debug = fn;
|
||||
});
|
||||
|
||||
/** @typedef {import('internal/modules/cjs/loader.js').Module} Module */
|
||||
/**
|
||||
* @typedef {(specifier: string, context: ModuleResolveContext, nextResolve: ResolveHook)
|
||||
* => ModuleResolveResult} ResolveHook
|
||||
* @typedef {(url: string, context: ModuleLoadContext, nextLoad: LoadHook)
|
||||
* => ModuleLoadResult} LoadHook
|
||||
* @typedef {import('internal/modules/cjs/loader.js').Module} Module
|
||||
*/
|
||||
/**
|
||||
* @typedef {(
|
||||
* specifier: string,
|
||||
* context: Partial<ModuleResolveContext>,
|
||||
* ) => ModuleResolveResult
|
||||
* } NextResolve
|
||||
* @typedef {(
|
||||
* specifier: string,
|
||||
* context: ModuleResolveContext,
|
||||
* nextResolve: NextResolve,
|
||||
* ) => ModuleResolveResult
|
||||
* } ResolveHook
|
||||
* @typedef {(
|
||||
* url: string,
|
||||
* context: Partial<ModuleLoadContext>,
|
||||
* ) => ModuleLoadResult
|
||||
* } NextLoad
|
||||
* @typedef {(
|
||||
* url: string,
|
||||
* context: ModuleLoadContext,
|
||||
* nextLoad: NextLoad,
|
||||
* ) => ModuleLoadResult
|
||||
* } LoadHook
|
||||
*/
|
||||
|
||||
// Use arrays for better insertion and iteration performance, we don't care
|
||||
// about deletion performance as much.
|
||||
|
||||
/** @type {ResolveHook[]} */
|
||||
const resolveHooks = [];
|
||||
/** @type {LoadHook[]} */
|
||||
const loadHooks = [];
|
||||
const hookId = Symbol('kModuleHooksIdKey');
|
||||
let nextHookId = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue