-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.js
44 lines (30 loc) · 914 Bytes
/
update.js
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
33
34
35
36
37
38
39
40
41
42
43
44
const object_path = require('object-path');
// WIP
// const statusTransform = {
// engine : {
// rpm : (input) => {
// return Math.round(input);
// },
// },
// };
class update {
// update.config('system.host_data.refresh_interval', 15000, false);
config(key, valueNew, quiet) {
const valueOld = object_path.get(config, key);
if (valueNew === valueOld) return false;
const keyFull = 'config.' + key;
if (quiet !== true) log.change({ keyFull, valueNew });
object_path.set(config, key, valueNew);
return true;
}
// update.status('engine.rpm', 1235, false);
status(key, valueNew, quiet = false) {
const valueOld = object_path.get(status, key);
if (valueNew === valueOld) return false;
object_path.set(status, key, valueNew);
const keyFull = 'status.' + key;
if (quiet !== true) log.change({ keyFull, valueNew });
return true;
}
}
module.exports = update;