import { Redis } from "ioredis"; type MutatingMethod = | "push" | "remove" | "removeIndex" | "pop" | "shift" | "unshift"; type NonMutatingMethod = | "concat" | "find" | "findIndex" | "includes" | "indexOf" | "lastIndexOf" | "map" | "length" | "filter" | "join" | "forEach"; type SupportedArrayMethod = MutatingMethod | NonMutatingMethod; interface Constants { MutatingMethod: MutatingMethod[]; NonMutatingMethod: NonMutatingMethod[]; SupportedArrayMethod: SupportedArrayMethod[]; } interface RediteOptions { client?: Redis; url?: string; serialise?: (value: any) => string; parse?: (value: string) => any; deletedString?: string; ignoreUndefinedValues?: boolean; } declare function r(options?: RediteOptions): r.Redite; declare namespace r { // Needs to be an interface in order to have a callable type. interface ChildWrapper { _stack: string[]; finally(onfinally?: (() => void) | undefined | null): Promise; then( onfulfilled?: ((value: any) => any) | undefined | null, onrejected?: ((reason: any) => any) | undefined | null ): Promise; catch(onrejected?: ((reason: any) => any) | undefined | null): Promise; new (parentObj: Redite, parentKey: string, stack?: string[]); set(value: any): Promise; has(key?: string): Promise; exists(key?: string): Promise; delete(key?: string): Promise; // Array method emulators push(...values): Promise; pop(): Promise; shift(): Promise; unshift(...values): Promise; remove(value, amount?: number): Promise; removeIndex(index: number): Promise; concat(...values): Promise; find( callback: (value, index?: number, array?: any[]) => boolean, thisArg? ): Promise; findIndex( callback: (value, index?: number, array?: any[]) => boolean, thisArg? ): Promise; includes(value, startIndex?: number): Promise; indexOf(value, startIndex?: number): Promise; lastIndexOf(value, startIndex?: number): Promise; map( callback: (value, index?: number, array?: any[]) => any, thisArg? ): Promise; filter( callback: (value, index?: number, array?: any[]) => boolean, thisArg? ): Promise; join(separator?: string): Promise; forEach( callback: (value, index?: number, array?: any[]) => void, thisArg? ): Promise; length(): Promise; // Emulates proxy behaviour. [key: string]: ChildWrapper | any; [key: number]: ChildWrapper | any; } export class Redite { $redis: Redis; $serialise: (value: any) => string; $parse: (value: string) => any; $deletedString: string; $ignoreUndefinedValues: boolean; constructor(options?: RediteOptions); has(key: string): Promise; delete(key: string): Promise; getStack(key: string, stack?: string[]): Promise; setStack(value: any, stack?: string[]): Promise; deleteStack(key: string, stack?: string[]): Promise; hasStack(key: string, stack?: string[]): Promise; arrayStack(method: string, stack?: string[]): (...args) => Promise; [key: string]: ChildWrapper | any; [key: number]: ChildWrapper | any; } export const Constants: Constants; export const ChildWrapper: ChildWrapper; } export = r;