Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Readme

A very simple demo of lunr, an in-memory text search that's perfect for Valtown

1
2
3
4
5
6
7
8
9
10
11
12
13
import lunr from 'https://cdn.skypack.dev/lunr';
const idx = lunr(function () {
this.field('content');
this.add({ id: 1, content: 'Banana Apples and Oranges' });
this.add({ id: 2, content: 'Cats Dogs and Bears' });
});
let results = idx.search('pear');
console.log(JSON.stringify(results));
results = idx.search('apple');
console.log(JSON.stringify(results));
June 12, 2024