MCPcopy
hub / github.com/Chalarangelo/30-seconds-of-code / prepare

Function prepare

src/astro/scripts/omnisearch.js:17–35  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15 focusedResult: -1,
16 isOpen: false,
17 prepare() {
18 if (!this.searchIndexInitialized)
19 fetch('/search-data.json')
20 .then(data => data.json())
21 .then(json => {
22 const documents = json.searchIndex.map(
23 ({ url, searchTokens, ...data }) => ({
24 id: url,
25 content: deserializeTokens(searchTokens),
26 rawContent: searchTokens,
27 url,
28 ...data,
29 })
30 );
31 this.searchIndex = new DocumentIndex(documents);
32 this.searchDocuments = search(this.searchIndex);
33 this.searchIndexInitialized = true;
34 });
35 },
36 open() {
37 this.prepare();
38 this.initializeSearchIconAnimation();

Callers

nothing calls this directly

Calls 3

deserializeTokensFunction · 0.90
mapMethod · 0.80
searchFunction · 0.70

Tested by

no test coverage detected