Options
All
  • Public
  • Public/Protected
  • All
Menu

Data packet storage based on LevelDB or other abstract-leveldown store.

Hierarchy

  • TypedEventEmitter<Events, this>
    • DataStore

Implements

  • Close
  • ListNames
  • ListData
  • Get
  • Find
  • Insert<InsertOptions>
  • Delete

Index

Constructors

constructor

  • new DataStore(db: AbstractLevelDOWN<any, any>): DataStore
  • Constructor.

    Parameters

    • db: AbstractLevelDOWN<any, any>

      an abstract-leveldown compatible store. It must support Buffer as keys.

    Returns DataStore

Properties

Readonly mutex

mutex: <TResult, TArgs>(fn: (...args: TArgs) => Promise<TResult>, ...args: TArgs) => Promise<TResult> = ...

Type declaration

    • <TResult, TArgs>(fn: (...args: TArgs) => Promise<TResult>, ...args: TArgs): Promise<TResult>
    • Create a throttle that only allows size calls in parallel. Extra calls will be queued until one of the earlier calls completes.

      To create an exclusive lock, just use a size of 1.

      Type parameters

      • TResult

      • TArgs: any[] = []

      Parameters

      • fn: (...args: TArgs) => Promise<TResult>
          • (...args: TArgs): Promise<TResult>
          • Parameters

            • Rest ...args: TArgs

            Returns Promise<TResult>

      • Rest ...args: TArgs

      Returns Promise<TResult>

Methods

clearExpired

  • clearExpired(): Promise<void>

close

  • close(): Promise<void>

delete

  • delete(...names: Name[]): Promise<void>

find

  • find(interest: Interest): Promise<undefined | Data>
  • Find Data that satisfies Interest.

    Parameters

    • interest: Interest

    Returns Promise<undefined | Data>

get

  • get(name: Name): Promise<undefined | Data>

insert

  • insert(...args: (Data | AnyIterable<Data>)[] | [InsertOptions, ...(Data | AnyIterable<Data>)[]]): Promise<void>
  • Insert one or more Data packets.

    Parameters

    • Rest ...args: (Data | AnyIterable<Data>)[] | [InsertOptions, ...(Data | AnyIterable<Data>)[]]

    Returns Promise<void>

listData

  • listData(prefix?: Name): AsyncIterable<Data>
  • List Data packets, optionally filtered by name prefix.

    Parameters

    • Optional prefix: Name

    Returns AsyncIterable<Data>

listNames

  • listNames(prefix?: Name): AsyncIterable<Name>
  • List Data names, optionally filtered by name prefix.

    Parameters

    • Optional prefix: Name

    Returns AsyncIterable<Name>

tx

Generated using TypeDoc