mirror of
https://github.com/logos-messaging/js-waku.git
synced 2026-01-09 01:03:11 +00:00
* move protocol result type to interfaces * chore: update type names for verbosity * feat(filter-core): convert error throws to return types * chore: update types & imports * update Filter API * chore: update createSubscription * chore: update imports & rename * chore: update all tests * chore: resolve conflicts & merge (2/n) * chore: resolve conflicts & merge (3/n) * chore: resolve conflicts & merge (4/n) * chore: resolve conflicts & merge (5/n) * chore: resolve conflicts & merge (6/n) * chore: use idiomatic approach * chore: fix tests * chore: address comments * chore: fix test * rm: only
35 lines
879 B
TypeScript
35 lines
879 B
TypeScript
import type { IDecodedMessage } from "./message.js";
|
|
import { ProtocolError } from "./protocols.js";
|
|
|
|
export interface IAsyncIterator<T extends IDecodedMessage> {
|
|
iterator: AsyncIterator<T>;
|
|
stop: Unsubscribe;
|
|
}
|
|
|
|
export type Unsubscribe = () => void | Promise<void>;
|
|
|
|
export type PubsubTopic = string;
|
|
export type ContentTopic = string;
|
|
|
|
export type PeerIdStr = string;
|
|
|
|
// SK = success key name
|
|
// SV = success value type
|
|
// EK = error key name (default: "error")
|
|
// EV = error value type (default: ProtocolError)
|
|
export type ThisOrThat<
|
|
SK extends string,
|
|
SV,
|
|
EK extends string = "error",
|
|
EV = ProtocolError
|
|
> =
|
|
| ({ [key in SK]: SV } & { [key in EK]: null })
|
|
| ({ [key in SK]: null } & { [key in EK]: EV });
|
|
|
|
export type ThisAndThat<
|
|
SK extends string,
|
|
SV,
|
|
EK extends string = "error",
|
|
EV = ProtocolError
|
|
> = { [key in SK]: SV } & { [key in EK]: EV };
|