Files
favicon-trap/typing/favicon.d.ts
2018-11-27 22:20:14 +08:00

34 lines
1.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* favicon的获取顺序为
* 1、 拉取指定网址并检测html代码中header->link标签是否存在favicon如果存在则使用它们。
* 2、当第一步不满足的时候回进行猜测一般猜测 favicon.ico、 favicon.png、 favicon.svg、favicon.gif如果存在并且mime类型是图片则返回。
* 3、如果上面两步都不满足则表示未找到favicon
*/
/** favicon option */
export interface FaviconOption {
/** icon types that be allowed, such as: "icon"、"apple-touch-icon" default: ['icon'] */
types?: Array<string>;
/** timeout of request, default: 5000 */
timeout?: number;
/** headers for http(s) request */
headers?: {
[i: string]: any;
};
}
/** return value of favicon function */
export interface FavIcon {
/** url of favicon */
url: string;
/** size of favicon, when: `<link ... size="128x128" />` */
size?: {
width: number;
height: number;
};
}
/**
* get favicon from given url
* @param uri URL
* @param option Optional
*/
export declare function favicon(uri: string, option?: FaviconOption): Promise<FavIcon[]>;