( store: CommandAliasStore | null | undefined )
| 74 | * 4. 移除归一化后为空的 commandId bucket |
| 75 | */ |
| 76 | export function normalizeCommandAliases( |
| 77 | store: CommandAliasStore | null | undefined |
| 78 | ): CommandAliasStore { |
| 79 | const normalized: CommandAliasStore = {} |
| 80 | |
| 81 | for (const [commandId, aliases] of Object.entries(store || {})) { |
| 82 | const nextAliases = Array.from( |
| 83 | new Map( |
| 84 | ((aliases || []) as Array<string | CommandAliasEntry>) |
| 85 | .map((aliasEntry) => { |
| 86 | if (typeof aliasEntry === 'string') { |
| 87 | return { alias: aliasEntry.trim(), icon: undefined } |
| 88 | } |
| 89 | |
| 90 | return { |
| 91 | alias: (aliasEntry?.alias || '').trim(), |
| 92 | icon: aliasEntry?.icon || undefined |
| 93 | } |
| 94 | }) |
| 95 | .filter((aliasEntry) => Boolean(aliasEntry.alias)) |
| 96 | .map((aliasEntry) => [aliasEntry.alias, aliasEntry] as const) |
| 97 | ).values() |
| 98 | ) |
| 99 | |
| 100 | if (nextAliases.length > 0) { |
| 101 | normalized[commandId] = nextAliases |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | return normalized |
| 106 | } |
no outgoing calls
no test coverage detected