Skip to content

Commit

Permalink
🔧
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvain-abadie committed Jul 19, 2022
1 parent 8ccecdd commit fa729ac
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/fake.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
9 changes: 2 additions & 7 deletions src/fake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand Down

0 comments on commit fa729ac

Please sign in to comment.