INNER CODE UNIT · TypeScript

selected

akirarika/milkio · packages/cookbook/src/index.ts:156

    const selected = await (async () => {
      const { controller, timeoutId } = createPromptAbortController();
      try {
        return await search(
          {
            message: "What kind of command:",
            source: async (input) => {
              if (!input) return commands;
              const filtered = commands.filter((command) => containsCharsInOrder(input.toLowerCase(), command.name.toLowerCase()));

              return uniqWith(filtered, (a, b) => a.value === b.value).sort((a, b) => {
                const scoreA = calculateScore(input, a.name);
                const scoreB = calculateScore(input, b.name);

                if (scoreB.maxContiguous !== scoreA.maxContiguous) {
                  return scoreB.maxContiguous - scoreA.maxContiguous;
                }

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…