feat: removeData
This commit is contained in:
parent
b3087ac4d3
commit
bcbef693cc
|
@ -1,4 +1,4 @@
|
||||||
import {get, set} from 'idb-keyval';
|
import {del, get, set} from 'idb-keyval';
|
||||||
|
|
||||||
import {encode} from '@/packets/index.js';
|
import {encode} from '@/packets/index.js';
|
||||||
|
|
||||||
|
@ -27,6 +27,9 @@ class WorkerServer extends Server {
|
||||||
error.code = 'ENOENT';
|
error.code = 'ENOENT';
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
async removeData(path) {
|
||||||
|
await del(this.constructor.qualify(path));
|
||||||
|
}
|
||||||
async writeData(path, view) {
|
async writeData(path, view) {
|
||||||
await set(this.constructor.qualify(path), view);
|
await set(this.constructor.qualify(path), view);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import {mkdir, readFile, writeFile} from 'node:fs/promises';
|
import {mkdir, readFile, unlink, writeFile} from 'node:fs/promises';
|
||||||
import {dirname, join} from 'node:path';
|
import {dirname, join} from 'node:path';
|
||||||
|
|
||||||
import {WebSocketServer} from 'ws';
|
import {WebSocketServer} from 'ws';
|
||||||
|
@ -64,6 +64,9 @@ class SocketServer extends Server {
|
||||||
await this.ensurePath(dirname(qualified));
|
await this.ensurePath(dirname(qualified));
|
||||||
return readFile(qualified);
|
return readFile(qualified);
|
||||||
}
|
}
|
||||||
|
async removeData(path) {
|
||||||
|
await unlink(path);
|
||||||
|
}
|
||||||
async writeData(path, view) {
|
async writeData(path, view) {
|
||||||
const qualified = this.constructor.qualify(path);
|
const qualified = this.constructor.qualify(path);
|
||||||
await this.ensurePath(dirname(qualified));
|
await this.ensurePath(dirname(qualified));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user