MCPcopy Index your code
hub / github.com/microsoft/typescript-go / GetNodeModulesPackageName

Function GetNodeModulesPackageName

internal/modulespecifiers/util.go:343–359  ·  view source on GitHub ↗
(
	compilerOptions *core.CompilerOptions,
	importingSourceFile *ast.SourceFile, // !!! | FutureSourceFile
	nodeModulesFileName string,
	host ModuleSpecifierGenerationHost,
	preferences UserPreferences,
	options ModuleSpecifierOptions,
)

Source from the content-addressed store, hash-verified

341}
342
343func GetNodeModulesPackageName(
344 compilerOptions *core.CompilerOptions,
345 importingSourceFile *ast.SourceFile, // !!! | FutureSourceFile
346 nodeModulesFileName string,
347 host ModuleSpecifierGenerationHost,
348 preferences UserPreferences,
349 options ModuleSpecifierOptions,
350) string {
351 info := getInfo(importingSourceFile.FileName(), host)
352 modulePaths := getAllModulePaths(info, nodeModulesFileName, host, compilerOptions, preferences, options)
353 for _, modulePath := range modulePaths {
354 if result := tryGetModuleNameAsNodeModule(modulePath, info, importingSourceFile, host, compilerOptions, preferences, true /*packageNameOnly*/, options.OverrideImportMode); len(result) > 0 {
355 return result
356 }
357 }
358 return ""
359}
360
361func allKeysStartWithDot(obj *collections.OrderedMap[string, packagejson.ExportsOrImports]) bool {
362 for k := range obj.Keys() {

Callers

nothing calls this directly

Calls 5

getInfoFunction · 0.85
getAllModulePathsFunction · 0.85
lenFunction · 0.85
FileNameMethod · 0.65

Tested by

no test coverage detected