diff --git a/types/lil-uri/index.d.ts b/types/lil-uri/index.d.ts index ec2bb5bf11..b9642657fd 100644 --- a/types/lil-uri/index.d.ts +++ b/types/lil-uri/index.d.ts @@ -4,204 +4,211 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /** - * Factory function to get a new URI instance. - * @param uri + * Global exposed when library is used outside of a module environment. */ -export default function uri(uri?: string): URI; +export as namespace lil; /** - * Provides access to URI component values and parser/builder functions. + * Exported function */ -export class URI { - /** - * Creates a new URI instance - * @param uri the URI string - */ - constructor(uri?: string); - - /** - * Parses the given URI string - * @param uri the URI to parse - */ - parse(uri: string): URIParts; - - /** - * Builds URI components into a URI string - */ - build(): string; - - /** - * Builds URI components into a URI string - */ - toString(): string; - - /** - * Builds URI components into a URI string - */ - valueOf(): string; - - /** - * Gets the protocol value - */ - protocol(): string; - - /** - * Sets the protocol - * @param protocol the protocol - * @return this object - */ - protocol(protocol: string): URI; - - /** - * Gets the host value - */ - host(): string; - - /** - * Sets the host - * @param host the host - * @return this object - */ - host(host: string): URI; - - /** - * Gets the hostname value - */ - hostname(): string; - - /** - * Sets the hostname - * @param hostname the hostname - * @return this object - */ - hostname(hostname: string): URI; - - /** - * Gets the port value - */ - port(): number; - - /** - * Sets the port - * @param port the port - * @return this object - */ - port(port: string): URI; - - /** - * Gets the auth value - */ - auth(): Credentials; - - /** - * Sets the auth - * @param auth the auth - * @return this object - */ - auth(auth: string): URI; - - /** - * Gets the user value - */ - user(): string; - - /** - * Sets the user - * @param user the user - * @return this object - */ - user(user: string): URI; - - /** - * Gets the password value - */ - password(): string; - - /** - * Sets the password - * @param password the password - * @return this object - */ - password(password: string): URI; - - /** - * Gets the path value - */ - path(): string; - - /** - * Sets the path - * @param path the path - * @return this object - */ - path(path: string): URI; - - /** - * Gets the search value - */ - search(): string; - - /** - * Sets the search - * @param search the search - * @return this object - */ - search(search: string): URI; - - /** - * Gets the query value - */ - query(): QueryString; - - /** - * Sets the query - * @param query the query - * @return this object - */ - query(query: QueryString): URI; - - /** - * Gets the hash value - */ - hash(): string; - - /** - * Sets the hash - * @param hash the hash - * @return this object - */ - hash(hash: string): URI; -} +export = uri; /** - * URI parts + * Parses the given URI string + * + * @param the URI string to parse. */ -export interface URIParts { - uri: string; - protocol: string; - host: string; - hostname: string; - port: string; - auth: string; - user: string; - password: string; - path: string; - search: string; - query: QueryString; - hash: string; -} +declare function uri(uri?: string): uri.URI; -/** - * Map of query string keys and values - */ -export interface QueryString { - [key: string]: string|string[]; -} +declare namespace uri { + /** + * Provides access to URI component values and parser/builder functions. + */ + interface URI { + /** + * Parses the given URI string + * @param uri the URI to parse + */ + parse(uri: string): URIParts; -/** - * Credentials map - */ -export interface Credentials { - user: string; - password: string; + /** + * Builds URI components into a URI string + */ + build(): string; + + /** + * Builds URI components into a URI string + */ + toString(): string; + + /** + * Builds URI components into a URI string + */ + valueOf(): string; + + /** + * Gets the protocol value + */ + protocol(): string; + + /** + * Sets the protocol + * @param protocol the protocol + * @return this object + */ + protocol(protocol: string): URI; + + /** + * Gets the host value + */ + host(): string; + + /** + * Sets the host + * @param host the host + * @return this object + */ + host(host: string): URI; + + /** + * Gets the hostname value + */ + hostname(): string; + + /** + * Sets the hostname + * @param hostname the hostname + * @return this object + */ + hostname(hostname: string): URI; + + /** + * Gets the port value + */ + port(): number; + + /** + * Sets the port + * @param port the port + * @return this object + */ + port(port: string): URI; + + /** + * Gets the auth value + */ + auth(): Credentials; + + /** + * Sets the auth + * @param auth the auth + * @return this object + */ + auth(auth: string): URI; + + /** + * Gets the user value + */ + user(): string; + + /** + * Sets the user + * @param user the user + * @return this object + */ + user(user: string): URI; + + /** + * Gets the password value + */ + password(): string; + + /** + * Sets the password + * @param password the password + * @return this object + */ + password(password: string): URI; + + /** + * Gets the path value + */ + path(): string; + + /** + * Sets the path + * @param path the path + * @return this object + */ + path(path: string): URI; + + /** + * Gets the search value + */ + search(): string; + + /** + * Sets the search + * @param search the search + * @return this object + */ + search(search: string): URI; + + /** + * Gets the query value + */ + query(): QueryString; + + /** + * Sets the query + * @param query the query + * @return this object + */ + query(query: QueryString): URI; + + /** + * Gets the hash value + */ + hash(): string; + + /** + * Sets the hash + * @param hash the hash + * @return this object + */ + hash(hash: string): URI; + } + + /** + * URI parts + */ + interface URIParts { + uri: string; + protocol: string; + host: string; + hostname: string; + port: string; + auth: string; + user: string; + password: string; + path: string; + search: string; + query: QueryString; + hash: string; + } + + /** + * Map of query string keys and values + */ + interface QueryString { + [key: string]: string|string[]; + } + + /** + * Credentials map + */ + interface Credentials { + user: string; + password: string; + } } diff --git a/types/lil-uri/lil-uri-tests.ts b/types/lil-uri/lil-uri-tests.ts index cb146e160d..0674e9422a 100644 --- a/types/lil-uri/lil-uri-tests.ts +++ b/types/lil-uri/lil-uri-tests.ts @@ -1,4 +1,4 @@ -import uri from 'lil-uri'; +import uri = require('lil-uri'); // // Tests are based on code samples on https://github.com/lil-js/uri#readme