-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmod.js
More file actions
29 lines (25 loc) · 665 Bytes
/
mod.js
File metadata and controls
29 lines (25 loc) · 665 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { DB, path } from './deps.js'
import dal from './dal.js'
import sal from './sal.js'
import adapter from './adapter.js'
export default function (config = { dir: '.' }) {
return ({
id: 'minisearch',
port: 'search',
load: () => {
const db = new DB(path.join(config.dir, 'hyper-search.db'))
self.addEventListener('unload', () => {
console.log('closing search db')
if (db) {
try {
db.close(true)
} catch (e) {
console.log('ERROR CLOSING DB: ', e)
}
}
})
return ({ db: dal(db), se: sal() })
},
link: (env) => () => adapter(env),
})
}