MCPcopy
hub / github.com/jestjs/jest / getSortedUsageRows

Function getSortedUsageRows

packages/jest-core/src/lib/watchPluginsHelpers.ts:31–56  ·  view source on GitHub ↗
(
  watchPlugins: Array<WatchPlugin>,
  globalConfig: Config.GlobalConfig,
)

Source from the content-addressed store, hash-verified

29};
30
31export const getSortedUsageRows = (
32 watchPlugins: Array<WatchPlugin>,
33 globalConfig: Config.GlobalConfig,
34): Array<UsageData> =>
35 filterInteractivePlugins(watchPlugins, globalConfig)
36 .sort((a: WatchPlugin, b: WatchPlugin) => {
37 if (a.isInternal && b.isInternal) {
38 // internal plugins in the order we specify them
39 return 0;
40 }
41 if (a.isInternal !== b.isInternal) {
42 // external plugins afterwards
43 return a.isInternal ? -1 : 1;
44 }
45
46 const usageInfoA = a.getUsageInfo && a.getUsageInfo(globalConfig);
47 const usageInfoB = b.getUsageInfo && b.getUsageInfo(globalConfig);
48
49 if (usageInfoA && usageInfoB) {
50 // external plugins in alphabetical order
51 return usageInfoA.key.localeCompare(usageInfoB.key);
52 }
53 return 0;
54 })
55 .map(p => p.getUsageInfo && p.getUsageInfo(globalConfig))
56 .filter(isNonNullable);

Callers 2

onKeypressFunction · 0.90
usageFunction · 0.90

Calls 3

filterInteractivePluginsFunction · 0.85
sortMethod · 0.45
getUsageInfoMethod · 0.45

Tested by

no test coverage detected