added doga
This commit is contained in:
30
25_02_24/node_modules/json-server/lib/observer.js
generated
vendored
Normal file
30
25_02_24/node_modules/json-server/lib/observer.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
// Lowdb adapter to observe read/write events
|
||||
export class Observer {
|
||||
#adapter;
|
||||
onReadStart = function () {
|
||||
return;
|
||||
};
|
||||
onReadEnd = function () {
|
||||
return;
|
||||
};
|
||||
onWriteStart = function () {
|
||||
return;
|
||||
};
|
||||
onWriteEnd = function () {
|
||||
return;
|
||||
};
|
||||
constructor(adapter) {
|
||||
this.#adapter = adapter;
|
||||
}
|
||||
async read() {
|
||||
this.onReadStart();
|
||||
const data = await this.#adapter.read();
|
||||
this.onReadEnd(data);
|
||||
return data;
|
||||
}
|
||||
async write(arg) {
|
||||
this.onWriteStart();
|
||||
await this.#adapter.write(arg);
|
||||
this.onWriteEnd();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user