import { RecordCore, WriteAckCallback } from './record-core'; import { Emitter } from '../util/emitter'; type ListSubscriptionCallback = (entries: string[]) => void; export declare class Dequeue extends Emitter { private record; debugId: string | null; private wrappedFunctions; private originalApplyUpdate; private beforeStructure; private headPath; private emptyHead; private hasAddListener; private hasRemoveListener; private hasMoveListener; private subscriptions; private lastEntries; private lastVersion; constructor(record: RecordCore); get name(): string; get isReady(): boolean; get version(): number; whenReady(): Promise; whenReady(callback: ((dq: Dequeue) => void)): void; discard(): void; delete(callback: (error: string | null) => void): void; delete(): Promise; /** * Returns the array of list entries or an * empty array if the list hasn't been populated yet. */ getEntries(): string[]; /** * Returns true if the list is empty */ isEmpty(): boolean; /** * Updates the list with a new set of entries */ setEntriesWithAck(entries: string[]): Promise; setEntriesWithAck(entries: string[], callback: WriteAckCallback): void; /** * Updates the list with a new set of entries */ setEntries(entries: string[], callback?: WriteAckCallback): void; /** * Get last entry */ getLast(): string; /** * Get first entry */ getFirst(): string; /** * Remove last value and return it * */ pop(): string; /** * Remove first value and return it */ shift(): string; /** * Get first available key for inserting node */ private getNodeKey; /** * Add value at first position. Issues a single atomic PATCH_MULTI message * to the server (one version bump, no race window between sub-writes). * Pass a callback (or use unshiftWithAck) to detect errors on old servers * that reject PATCH_MULTI as INVALID_MESSAGE_DATA — the caller can then * fall back to setEntries with the desired ordering. * * @param {String} entry */ unshift(entry: string, callback?: WriteAckCallback): void; unshiftWithAck(entry: string): Promise; unshiftWithAck(entry: string, callback: WriteAckCallback): void; /** * Add value at last position. See unshift() for atomicity semantics. * * @param {String} entry */ push(entry: string, callback?: WriteAckCallback): void; pushWithAck(entry: string): Promise; pushWithAck(entry: string, callback: WriteAckCallback): void; /** * Remove a node — atomic PATCH_MULTI batch updating neighbour pointers, * head pointers if needed, and erasing the node itself. */ private removeNode; /** * Removes an entry from the list. If no index is given it will remove the first occurrence * * @param {String} entry * @param {Number} [index] */ removeEntry(entry: string, index?: number): void; /** * Inserts an entry in the list. At index 0 is equivalent to unshift, at index = entries.length - 1 it will be inserted before last node, unlike push. * * @param {String} entry * @param {Number} [index] */ insertEntry(entry: string, index: number, callback?: WriteAckCallback): void; /** * Proxies the underlying Record's subscribe method. */ subscribe(callback: ListSubscriptionCallback): void; subscribe(position: string, callback: ListSubscriptionCallback): void; /** * Proxies the underlying Record's unsubscribe method. Makes sure * that no path is provided */ unsubscribe(callback: ListSubscriptionCallback): void; unsubscribe(position: string, callback: ListSubscriptionCallback): void; /** * Proxies the underlying Record's _update method. */ private applyUpdate; /** * Validates that the index provided is within the current set of entries. */ private hasIndex; /** * Establishes the current structure of the list, provided the client has attached any * add / move / remove listener * * This will be called before any change to the list, regardsless if the change was triggered * by an incoming message from the server or by the client */ private beforeChange; /** * Compares the structure of the list after a change to its previous structure and notifies * any add / move / remove listener. Won't do anything if no listeners are attached. */ private afterChange; /** * Iterates through the list and creates a map with the entry as a key * and an array of its position(s) within the list as a value, e.g. * * { * 'recordA': [ 0, 3 ], * 'recordB': [ 1 ], * 'recordC': [ 2 ] * } */ private getStructure; private destroy; } export {};