UNPKG

928 BTypeScriptView Raw
1import { Readable } from 'readable-stream';
2import { Packet } from 'mqtt-packet';
3import { DoneCallback } from './shared';
4export interface IStoreOptions {
5 clean?: boolean;
6}
7export type PacketCallback = (error?: Error, packet?: Packet) => void;
8export interface IStore {
9 put(packet: Packet, cb: DoneCallback): IStore;
10 createStream(): Readable;
11 del(packet: Pick<Packet, 'messageId'>, cb: PacketCallback): IStore;
12 get(packet: Pick<Packet, 'messageId'>, cb: PacketCallback): IStore;
13 close(cb: DoneCallback): void;
14}
15export default class Store implements IStore {
16 private options;
17 private _inflights;
18 constructor(options?: IStoreOptions);
19 put(packet: Packet, cb: DoneCallback): this;
20 createStream(): Readable;
21 del(packet: Pick<Packet, 'messageId'>, cb: PacketCallback): this;
22 get(packet: Pick<Packet, 'messageId'>, cb: PacketCallback): this;
23 close(cb: DoneCallback): void;
24}