Deno and Bun
Import rapid-fuzzy with the npm: specifier:
import { search } from 'npm:rapid-fuzzy';
console.log(search('typscript', ['TypeScript', 'JavaScript', 'Python'])[0]?.item); // 'TypeScript'By default Deno loads the Node.js entry, which uses the native addon. That gives you the full Node.js API, including FuzzyObjectIndex serialization, and needs --allow-ffi:
deno run --allow-read --allow-env --allow-ffi main.tsTo use the WebAssembly build instead, without the FFI permission, add the browser condition. It reads its .wasm file from the npm cache, so it needs --allow-read:
deno run --conditions=browser --allow-read main.tsBun loads the native addon by default, which is the fastest option:
bun add rapid-fuzzybun run main.tsTo use the WebAssembly build, for example to test the code path your browser bundle takes, run with the browser condition:
bun --conditions=browser run main.tsbun build keeps the WebAssembly file’s new URL(...) reference but does not emit the file: copy node_modules/rapid-fuzzy/rapid-fuzzy-wasm-bindgen_bg.wasm next to the bundle (see Bundlers).