/
dropdead
/
frontend_trainee
Обзор
Документация
Войти
/
dropdead
/
frontend_trainee
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
node_modules/json-server/lib/observer.js
30 строк
648 B
Ivan
init: add server files and depdendcies from task
06 сен 2024, 20:55
06 сен 2024, 20:55
880ac28
Код
Авторство
О чём код?
// 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(); } }