mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-03-29 08:58:23 +08:00
Add 'page-icon' package (#11918)
This commit is contained in:
committed by
Masahiro Wakame
parent
7ab26a7f1e
commit
815ad66282
25
page-icon/page-icon-tests.ts
Normal file
25
page-icon/page-icon-tests.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
/// <reference path="./page-icon.d.ts" />
|
||||
|
||||
import * as pageIcon from "page-icon";
|
||||
|
||||
const siteUrl = "https://www.facebook.com/";
|
||||
pageIcon(siteUrl)
|
||||
.then(function(icon) {
|
||||
// do things with icon object
|
||||
console.log(icon);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
});
|
||||
|
||||
const twUrl = "https://twitter.com";
|
||||
pageIcon(twUrl, {ext: ".png"})
|
||||
.then(icon => {
|
||||
if (!icon) {
|
||||
return;
|
||||
}
|
||||
console.log(icon.source, icon.name, icon.data, icon.size, icon.ext, icon.mime);
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(err);
|
||||
});
|
||||
25
page-icon/page-icon.d.ts
vendored
Normal file
25
page-icon/page-icon.d.ts
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
// Type definitions for page-icon 0.3.0
|
||||
// Project: https://github.com/jiahaog/page-icon
|
||||
// Definitions by: rhysd <https://rhysd.github.io>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
declare namespace PageIcon {
|
||||
interface Icon {
|
||||
source: string;
|
||||
name: string;
|
||||
data: Buffer;
|
||||
size: number;
|
||||
ext: string;
|
||||
mime: string;
|
||||
}
|
||||
interface FetchOptions {
|
||||
ext?: string;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "page-icon" {
|
||||
const mod: (url: string, opts?: PageIcon.FetchOptions) => Promise<PageIcon.Icon>;
|
||||
export = mod;
|
||||
}
|
||||
Reference in New Issue
Block a user