Fuzer
A fuzzy search library written in golang with webassembly support
Report Bug
·
Request Feature
.
Demo
Table of Contents
About the project
Fuzer is a simple library to fuzzy autocomplete suggestions based on a simple ranking algorithm
Installing
First, use go get to install the latest version of the library. This command will download fuzer with all its dependencies:
go get -u github.com/arjit95/fuzer
Usage
Check out fuzer.go for sample usage.
Using with webassembly
First, we need to generate a wasm file which could be embedded inside a web page.
// clone the repository
git clone https://github.com/arjit95/fuzer
cd fuzer
// Build the wasm file
GOOS=js GOARCH=wasm go build -o main.wasm web/api.go
cp "$(go env GOROOT)/misc/wasm/wasm_exec.js" <path to your website folder>
cp main.wasm <path to your website folder>
A simple loader file is also provided. fuzer.js is present for loading the binary. After embedding the JS file in your page, it will export Fuzer to your global namespace.
<html>
<head>Fuzer Demo</head>
<body>
<script type="text/javascript" src="fuzer.js">
<script type="text/javascript">
async function loadLibrary() {
await Fuzer.load(<path to wasm binary>);
// your fuzer instance
const instance = Fuzer.getInstance();
}
</script>
</body>
A working sample is available at worker.js.
License
Distributed under the MIT License. See LICENSE for more information.