forked from HeyPuter/puter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata.js
More file actions
32 lines (26 loc) 路 915 Bytes
/
Copy pathdata.js
File metadata and controls
32 lines (26 loc) 路 915 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
30
31
32
//@extension priority -10000
const { DB_WRITE } = extension.import('core').database;
const svc_database = extension.import('service:database');
const svc_kvstore = extension.import('service:puter-kvstore');
// Methods on the object from `.as()` come from TraitsFeature.js,
// and they are already bound to their respective instance.
const simplified_kv = { ...svc_kvstore.as('puter-kvstore') };
const original_get = simplified_kv.get;
const original_set = simplified_kv.set;
simplified_kv.get = (...a) => {
if ( typeof a[0] === 'string' ) {
return original_get({ key: a[0] });
}
return original_get(...a);
};
simplified_kv.set = (...a) => {
if ( typeof a[0] === 'string' ) {
return original_set({ key: a[0], value: a[1] });
}
return original_set(...a);
};
extension.exports = {
db: svc_database.get(DB_WRITE, 'extensions'),
kv: simplified_kv,
cache: kv,
};