function inspectModule(
    moduleRecord,
    { isBuiltin, includeDebugInfo = false, trustRoot = true }
  ) {
    if (moduleRecord === undefined)
      // see https://github.com/LavaMoat/LavaMoat/pull/1471 for when this happens
      return

    const { packageName, specifier, type } = moduleRecord
    // record the module
    moduleIdToModuleRecord.set(specifier, moduleRecord)
    // call the correct analyzer for the module type
    switch (type) {
      case 'builtin': {
        inspectBuiltinModule(moduleRecord, { includeDebugInfo, trustRoot })
        return
      }
      case 'native': {
        inspectNativeModule(moduleRecord, { includeDebugInfo, trustRoot })
        return
      }
      case 'js': {
        inspectJsModule(moduleRecord, {
          isBuiltin,
          includeDebugInfo,
          trustRoot,
        })
        return
      }
      default: {
        const errMsg = `LavaMoat - unknown module type "${type}" for package "${packageName}" module "${specifier}"`
        throw new Error(errMsg)
      }
    }
  }
@param {import('./moduleRecord').LavamoatModuleRecord} moduleRecord
@param {ModuleInspectorOptions} opts