UNPKG

@tanislav000/bluez

Version:

Bluez5 D-Bus bindings for easy to use bluetooth access in Node.js

100 lines (99 loc) 4.44 kB
import * as DBus from "dbus-next"; export type ObjectVariantSignatures<T extends Record<string, any>> = Partial<Record<keyof T, string>>; export type ObjectVariants<T extends Record<string, any>> = Record<keyof T, DBus.Variant>; export declare function detectDbusType(v: any): string; /** * This will create `v` signature * @param obj */ export declare function wrapDbusVariant(obj: any, type?: string): DBus.Variant; /** * This will create `a{sv}` signature * @param obj */ export declare function wrapDbusVariantObject<O extends Record<string, any>>(obj: O, signatures?: ObjectVariantSignatures<O>): ObjectVariants<O>; /** * This will create `av` signature * @param obj */ export declare function wrapDbusVariantArray(obj: any[], signatures?: string[]): DBus.Variant[]; export declare function wrapDbusSignature(obj: any, type: string): any; /** * This unwarps `v` signatures * @param obj */ export declare function unwrapDbusVariant(obj: DBus.Variant): any; /** * This unwraps `a{sv}` signatures * @param obj */ export declare function unwrapDbusVariantObject(obj: { [key: string]: DBus.Variant; }): { [key: string]: any; }; /** * This unwraps `av` signatures * @param obj */ export declare function unwrapDbusVariantArray(obj: DBus.Variant[]): any[]; /** This unwraps anything */ export declare function unwrapDbusVariantAll(obj: any): any; export declare function unwrapDbusSignature(type: string): (obj: any) => any; type DefaultFunction = (...args: any[]) => any; export type EventListenerSignature<L> = { [E in keyof L]: DefaultFunction; }; export interface TypedEmitter<L extends EventListenerSignature<L> = Record<string, never>> { addListener<U extends keyof L>(event: U, listener: L[U]): this; prependListener<U extends keyof L>(event: U, listener: L[U]): this; prependOnceListener<U extends keyof L>(event: U, listener: L[U]): this; removeListener<U extends keyof L>(event: U, listener: L[U]): this; removeAllListeners(event?: keyof L): this; once<U extends keyof L>(event: U, listener: L[U]): this; on<U extends keyof L>(event: U, listener: L[U]): this; off<U extends keyof L>(event: U, listener: L[U]): this; emit<U extends keyof L>(event: U, ...args: Parameters<L[U]>): boolean; eventNames<U extends keyof L>(): U[]; listenerCount(type: keyof L): number; listeners<U extends keyof L>(type: U): L[U][]; rawListeners<U extends keyof L>(type: U): L[U][]; getMaxListeners(): number; setMaxListeners(n: number): this; } export declare const TypedEmitter: { new <L extends EventListenerSignature<L> = Record<string, never>>(): TypedEmitter<L>; }; export interface LooselyTypedEmitter<L extends EventListenerSignature<L> = Record<string, never>> { addListener<U extends keyof L>(event: U, listener: L[U]): this; addListener(event: string, listener: DefaultFunction): this; prependListener<U extends keyof L>(event: U, listener: L[U]): this; prependListener(event: string, listener: DefaultFunction): this; prependOnceListener<U extends keyof L>(event: U, listener: L[U]): this; prependOnceListener(event: string, listener: DefaultFunction): this; removeListener<U extends keyof L>(event: U, listener: L[U]): this; removeListener(event: string, listener: DefaultFunction): this; removeAllListeners(event?: keyof L): this; removeAllListeners(event?: string): this; once<U extends keyof L>(event: U, listener: L[U]): this; once(event: string, listener: DefaultFunction): this; on<U extends keyof L>(event: U, listener: L[U]): this; on(event: string, listener: DefaultFunction): this; off<U extends keyof L>(event: U, listener: L[U]): this; off(event: string, listener: DefaultFunction): this; emit<U extends keyof L>(event: U, ...args: Parameters<L[U]>): boolean; emit(event: string, ...args: any[]): boolean; eventNames<U extends keyof L>(): U[]; listenerCount(type: keyof L): number; listenerCount(type: string): number; listeners<U extends keyof L>(type: U): L[U][]; listeners(type: string): DefaultFunction[]; rawListeners<U extends keyof L>(type: U): L[U][]; rawListeners(type: string): DefaultFunction[]; getMaxListeners(): number; setMaxListeners(n: number): this; } export declare const LooselyTypedEmitter: { new <L extends EventListenerSignature<L> = Record<string, never>>(): LooselyTypedEmitter<L>; }; export {};