diff --git a/src/fake.test.ts b/src/fake.test.ts index 414f4eb..a269846 100644 --- a/src/fake.test.ts +++ b/src/fake.test.ts @@ -33,5 +33,5 @@ test('FakeLevelDB', () => { db.put('dbMetaverse', 'g'); expect(db.kv?.map(x => toString(x[0]))).toEqual(['db.farm.0', 'db.farm.1', 'dbMeta', 'dbMetaverse']) - expect(db.getStr('dbMeta')).toEqual('f'); + expect(db.get('dbMeta')).toEqual('f'); }); diff --git a/src/fake.ts b/src/fake.ts index 5d7fc20..54c9244 100644 --- a/src/fake.ts +++ b/src/fake.ts @@ -142,7 +142,7 @@ export class FakeLevelDB implements LevelDBI { return this.kv == null; } - put(k: ArrayBuffer | string, v: ArrayBuffer | string) { + put(k: ArrayBuffer | string, v: any) { const curIdx = getIdx(this.kv, k); // curIdx is the position at the first key in the source that is at or past `k`: if (curIdx == this.kv!.length) { @@ -164,12 +164,7 @@ export class FakeLevelDB implements LevelDBI { } } - getStr(k: ArrayBuffer | string): null | string { - const buf = this.getBuf(k); - return buf && toString(buf); - } - - getBuf(k: ArrayBuffer | string): null | ArrayBuffer { + get(k: ArrayBuffer | string): null | any { k = toArraybuf(k); const curIdx = getIdx(this.kv, k); const kv = curIdx < this.kv!.length ? this.kv![curIdx] : null;