ethereumjs-monorepo

@ethereumjs/util


@ethereumjs/util / MapDB

Class: MapDB<TKey, TValue>

Defined in: packages/util/src/mapDB.ts:5

Type Parameters

TKey

TKey extends Uint8Array | string | number

TValue

TValue extends Uint8Array | string | DBObject

Implements

Constructors

Constructor

new MapDB<TKey, TValue>(database?): MapDB<TKey, TValue>

Defined in: packages/util/src/mapDB.ts:12

Parameters

database?

Map<TKey, TValue>

Returns

MapDB<TKey, TValue>

Properties

_database

_database: Map<TKey, TValue>

Defined in: packages/util/src/mapDB.ts:10

Methods

batch()

batch(opStack): Promise<void>

Defined in: packages/util/src/mapDB.ts:31

Performs a batch operation on db.

Parameters

opStack

BatchDBOp<TKey, TValue>[]

A stack of levelup operations

Returns

Promise<void>

Implementation of

DB.batch


del()

del(key): Promise<void>

Defined in: packages/util/src/mapDB.ts:26

Removes a raw value in the underlying db.

Parameters

key

TKey

Returns

Promise<void>

Implementation of

DB.del


get()

get(key): Promise<undefined | TValue>

Defined in: packages/util/src/mapDB.ts:16

Retrieves a raw value from db.

Parameters

key

TKey

Returns

Promise<undefined | TValue>

A Promise that resolves to Uint8Array if a value is found or undefined if no value is found.

Implementation of

DB.get


open()

open(): Promise<void>

Defined in: packages/util/src/mapDB.ts:52

Opens the database – if applicable

Returns

Promise<void>

Implementation of

DB.open


put()

put(key, val): Promise<void>

Defined in: packages/util/src/mapDB.ts:21

Writes a value directly to db.

Parameters

key

TKey

The key as a TValue

val

TValue

Returns

Promise<void>

Implementation of

DB.put


shallowCopy()

shallowCopy(): DB<TKey, TValue>

Defined in: packages/util/src/mapDB.ts:48

Note that the returned shallow copy will share the underlying database with the original

Returns

DB<TKey, TValue>

DB

Implementation of

DB.shallowCopy