Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | 3763x 3763x 3763x 3763x | import { CommandBindpoint, useCommands } from "just-search-it";
import { useCallback } from "react";
function useHasCommand() {
const commands = useCommands();
function commandExists<Args extends any[], ReturnType>(
command: CommandBindpoint<Args, ReturnType>,
...args: Args
) {
// TODO: replace this line with getCommandKey from just-search-it
const commandKey =
command.key + "." + args.map((arg) => arg?.toString() || "").join(".");
return commands[commandKey] !== undefined;
}
return useCallback(commandExists, [commands]);
}
export { useHasCommand };
|