Class ContentAddressedMapStore<Id, T, M>

A content-addressable map store that persists values in a backing MaybeAsyncMap.

Type Parameters

Implements

Constructors

Properties

[asyncIterator]: M extends Iterable<[Id, T]> | AsyncIterable<[Id, T]>
    ? (() => AsyncIterableIterator<[Id, T]>)
    : undefined
[iterator]: M extends Iterable<[Id, T]>
    ? (() => IterableIterator<[Id, T]>)
    : undefined
getKey: ((value) => MaybePromise<Id>) = cidHash

Type declaration

    • (value): MaybePromise<Id>
    • Hash function to use for generating keys for values.

      Parameters

      • value: T

      Returns MaybePromise<Id>

map: M = ...

The underlying map.

put: ((...args) => any) = ...

Type declaration

    • (...args): any
    • Wraps a MaybePromise-yielding coroutine (generator function) into a function that returns MaybePromise. This allows you to use maybeAsync/yield in a similar way to async/await, where yield maybePromise will return awaited / resolved value.

      Parameters

      Returns any

      Example

      const add = maybeAsync(function* (a: number, b: number) {
      const result1: number = yield Promise.resolve(a); // result1 === a
      const result2 = yield b; // result2 === b
      return result + result2;
      });
      const result = await add(1, 2); // result === 3

Accessors

Methods

Generated using TypeDoc