Download src/hooks/useMergedCommands.ts from chenbhao/codev: direct link, hf CLI and curl.
- Browser
- Download file 423 Bytes
-
https://huggingface.co/chenbhao/codev/resolve/e91c8197c9918ff9e5df3140e8c36282bb30e9a2/src/hooks/useMergedCommands.ts
- Command line
-
hf download hf://chenbhao/codev@e91c8197c9918ff9e5df3140e8c36282bb30e9a2/src/hooks/useMergedCommands.ts
-
curl -L -o useMergedCommands.ts https://huggingface.co/chenbhao/codev/resolve/e91c8197c9918ff9e5df3140e8c36282bb30e9a2/src/hooks/useMergedCommands.ts
423 Bytes
| import uniqBy from 'lodash-es/uniqBy.js' | |
| import { useMemo } from 'react' | |
| import type { Command } from '../commands.js' | |
| export function useMergedCommands( | |
| initialCommands: Command[], | |
| mcpCommands: Command[], | |
| ): Command[] { | |
| return useMemo(() => { | |
| if (mcpCommands.length > 0) { | |
| return uniqBy([...initialCommands, ...mcpCommands], 'name') | |
| } | |
| return initialCommands | |
| }, [initialCommands, mcpCommands]) | |
| } | |