File tree 1 file changed +11
-1
lines changed
1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ const fs = require('fs');
2
2
let db = { } ;
3
3
updateDbVariable ( ) ;
4
4
5
+ // function initialize
6
+
5
7
function initialize ( ) {
6
8
try {
7
9
fs . readFileSync ( 'database.dbs' , 'utf-8' ) ;
@@ -16,6 +18,8 @@ function initialize() {
16
18
}
17
19
}
18
20
21
+ // refresher
22
+
19
23
function updateDbVariable ( ) {
20
24
try {
21
25
db = JSON . parse ( fs . readFileSync ( 'database.dbs' , 'utf-8' ) ) ;
@@ -24,6 +28,8 @@ function updateDbVariable() {
24
28
}
25
29
}
26
30
31
+ // refresher
32
+
27
33
function updateDb ( data ) {
28
34
try {
29
35
fs . writeFileSync ( 'database.dbs' , JSON . stringify ( data ) ) ;
@@ -32,6 +38,8 @@ function updateDb(data) {
32
38
}
33
39
}
34
40
41
+ // usable functions
42
+
35
43
function add ( key , value ) {
36
44
db [ key ] = value ;
37
45
updateDb ( db ) ;
@@ -53,10 +61,12 @@ function readAllData() {
53
61
return db ;
54
62
}
55
63
64
+ // exports
65
+
56
66
module . exports = {
57
67
initialize,
58
68
add,
59
69
get,
60
70
vanish,
61
71
readAllData
62
- }
72
+ }
You can’t perform that action at this time.
0 commit comments