From 8fe76934d9dfa71a2b166f885bab92c7480ef52b Mon Sep 17 00:00:00 2001 From: Peter Matta Date: Tue, 15 Jan 2019 22:10:25 -0600 Subject: [PATCH] Updated type definitions to comply with tslint --- types/react-native-zeroconf/index.d.ts | 181 +++++++++++-------------- 1 file changed, 80 insertions(+), 101 deletions(-) diff --git a/types/react-native-zeroconf/index.d.ts b/types/react-native-zeroconf/index.d.ts index 12d8dedc0e..91ee553a67 100644 --- a/types/react-native-zeroconf/index.d.ts +++ b/types/react-native-zeroconf/index.d.ts @@ -5,115 +5,94 @@ /// -declare module 'react-native-zeroconf' { +/** + * @example + * ```json + * { + * "host": "XeroxPrinter.local.", + * "addresses": [ + * "192.168.1.23", + * "fe80::aebc:123:ffff:abcd" + * ], + * "name": "Xerox Printer", + * "fullName": "XeroxPrinter.local._http._tcp.", + * "port": 8080, + * "txt": {} + * } + * ``` + */ +export interface Service { + name: string; + fullName: string; + addresses: string[]; + host: string; + port: number; + txt: { + [key: string]: any + }; +} + +export default class Zeroconf extends NodeJS.EventEmitter { /** - * @example - ```json - { - "host": "XeroxPrinter.local.", - "addresses": [ - "192.168.1.23", - "fe80::aebc:123:ffff:abcd" - ], - "name": "Xerox Printer", - "fullName": "XeroxPrinter.local._http._tcp.", - "port": 8080, - "txt": {} - } - ``` + * Start the zeroconf scan. + * + * @description This will initialize the scan from the `Zeroconf` + * instance. Will stop another scan if any is running. + * + * @param type Default `http` + * @param protocol Default `tcp` + * @param domain Default `local` */ - export interface Service { - name: string; - fullName: string; - addresses: string[]; - host: string; - port: number; - txt: { - [key: string]: any - }; - } + scan(type?: string, protocol?: string, domain?: string): void; - export default class Zeroconf extends NodeJS.EventEmitter { - /** - * Start the zeroconf scan. - * - * @description This will initialize the scan from the `Zeroconf` - * instance. Will stop another scan if any is running. - * - * @param type Default `http` - * @param protocol Default `tcp` - * @param domain Default `local` - */ - public scan(type?: string, protocol?: string, domain?: string): void; + /** + * Stop the scan. + * + * @description If any scan is running, stop it. Otherwise do nothing. + */ + stop(): void; - /** - * Stop the scan. - * - * @description If any scan is running, stop it. Otherwise do nothing. - */ - public stop(): void; + /** + * Returns resolved services. + * + * @description Will return all names of services that have been + * resolved. + */ + getServices(): { [name: string]: Service }; - /** - * Returns resolved services. - * - * @description Will return all names of services that have been - * resolved. - */ - public getServices(): { [name: string]: Service }; + /** + * Remove listeners. + * + * @description Allow you to clean the listeners, avoiding potential + * memory leaks. + * + * @see https://github.com/balthazar/react-native-zeroconf/issues/33 + */ + removeDeviceListeners(): void; - /** - * Remove listeners. - * - * @description Allow you to clean the listeners, avoiding potential - * memory leaks. - * - * @see https://github.com/balthazar/react-native-zeroconf/issues/33 - */ - public removeDeviceListeners(): void; + /** + * Add listeners + * + * @description If you cleaned the listeners and need to get them back + * on. + */ + addDeviceListeners(): void; - /** - * Add listeners - * - * @description If you cleaned the listeners and need to get them back - * on. - */ - public addDeviceListeners(): void; + on(e: 'start' | 'stop' | 'update', listener: () => any): this; - /** - * Triggered on scan start. - */ - public on(e: 'start', listener: () => any): this; + /** + * @param name Name of the the service. + */ + on(e: 'found' | 'remove', listener: (name: string) => any): this; - /** - * Triggered on scan stop - */ - public on(e: 'stop', listener: () => any): this; + /** + * Triggered when a service is resolved. + * @description Broadcast a service object once it is fully resolved. + */ + on(e: 'resolved', listener: (service: Service) => any): this; - /** - * Triggered either when a service is found or removed. - */ - public on(e: 'update', listener: () => any): this; - - /** - * Broadcast a service name as soon as it is found. - */ - public on(e: 'found', listener: (name: string) => any): this; - - /** - * Triggered when a service is resolved. - * @description Broadcast a service object once it is fully resolved. - */ - public on(e: 'resolved', listener: (service: Service) => any): this; - - /** - * Triggered when a service is removed. - * @description Broadcast a service name removed from the network. - */ - public on(e: 'remove', listener: (name: string) => any): this; - - /** - * Triggered when an error occurs. - */ - public on(e: 'error', listener: (err: Error) => any): this; - } + /** + * Triggered when an error occurs. + */ + on(e: 'error', listener: (err: Error) => any): this; }