firest commit

This commit is contained in:
wwweww
2026-02-21 22:48:40 +08:00
commit 55e8053e07
1034 changed files with 99049 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
import { search } from "@inquirer/prompts"
import Fuse from "fuse.js";
const colors = [
{ title: 'Red', value: 'red' },
{ title: 'Green', value: 'green' },
{ title: 'Blue', value: 'blue' },
{ title: 'Yellow', value: 'yellow' },
];
(async () => {
const fuse = new Fuse(colors, {
keys: ['title'],
threshold: 0.4,
})
const color = await search({
message: "Pick a color",
source: async (term) => {
if (!term) {
return colors.map(s => s.value);
}
const result = fuse.search(term);
return result.map(s => s.item.value);
}
})
console.log(color); // => { color: 'green' }
})();