Skip to content

Commit 25a1e7a

Browse files
committed
JS lint
1 parent d46959c commit 25a1e7a

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

assets/js/search-page.js

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ async function getIndex () {
5050
lunr.Pipeline.registerFunction(elixirTrimmerFunction, 'elixirTrimmer')
5151
lunr.Pipeline.registerFunction(hyphenSearchFunction, 'hyphenSearch')
5252

53-
const cachedIndex = await loadIndex()
53+
const cachedIndex = await loadIndex()
5454
if (cachedIndex) { return cachedIndex }
5555

5656
const index = createIndex()
@@ -75,52 +75,50 @@ async function loadIndex () {
7575

7676
async function saveIndex (index) {
7777
try {
78-
const serializedIndex = await compress(index)
78+
const serializedIndex = await compress(index)
7979
sessionStorage.setItem(indexStorageKey(), serializedIndex)
8080
} catch (error) {
8181
console.error('Failed to save index: ', error)
8282
}
8383
}
8484

85-
async function compress(index) {
86-
85+
async function compress (index) {
8786
const stream = new Blob([JSON.stringify(index)], {
88-
type: 'application/json',
89-
}).stream().pipeThrough(new CompressionStream('gzip'));
87+
type: 'application/json'
88+
}).stream().pipeThrough(new window.CompressionStream('gzip'))
9089

9190
const blob = await new Response(stream).blob()
9291
const buffer = await blob.arrayBuffer()
9392
return b64encode(buffer)
9493
}
9594

96-
97-
async function decompress(index) {
95+
async function decompress (index) {
9896
const stream = new Blob([b64decode(index)], {
99-
type: "application/json",
100-
}).stream().pipeThrough(new DecompressionStream('gzip'));
97+
type: 'application/json'
98+
}).stream().pipeThrough(new window.DecompressionStream('gzip'))
10199

102100
const blob = await new Response(stream).text()
103101
return JSON.parse(blob)
104102
}
105103

106-
function b64encode(buffer) {
107-
var binary = '';
108-
var bytes = new Uint8Array( buffer );
109-
var len = bytes.byteLength;
110-
for (var i = 0; i < len; i++) {
111-
binary += String.fromCharCode( bytes[ i ] );
112-
}
113-
return window.btoa( binary );
104+
function b64encode (buffer) {
105+
let binary = ''
106+
const bytes = new Uint8Array(buffer)
107+
const len = bytes.byteLength
108+
for (let i = 0; i < len; i++) {
109+
binary += String.fromCharCode(bytes[i])
110+
}
111+
return window.btoa(binary)
114112
}
115113

116-
function b64decode(str) {
117-
const binary_string = window.atob(str);
118-
const len = binary_string.length;
119-
const bytes = new Uint8Array(new ArrayBuffer(len));
114+
function b64decode (str) {
115+
const binaryString = window.atob(str)
116+
const len = binaryString.length
117+
const bytes = new Uint8Array(new ArrayBuffer(len))
120118
for (let i = 0; i < len; i++) {
121-
bytes[i] = binary_string.charCodeAt(i);
119+
bytes[i] = binaryString.charCodeAt(i)
122120
}
123-
return bytes;
121+
return bytes
124122
}
125123

126124
function indexStorageKey () {

0 commit comments

Comments
 (0)