mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-01-30 13:37:35 +00:00
Merge pull request #17861 from dolanmiu/google-images
Typings for google-images
This commit is contained in:
commit
d04c4eac62
27
types/google-images/google-images-tests.ts
Normal file
27
types/google-images/google-images-tests.ts
Normal file
@ -0,0 +1,27 @@
|
||||
import * as GoogleImages from "google-images";
|
||||
|
||||
const client = new GoogleImages('CSE ID', 'API KEY');
|
||||
|
||||
client.search('Steve Angello')
|
||||
.then(images => {
|
||||
/*
|
||||
[{
|
||||
"url": "http://steveangello.com/boss.jpg",
|
||||
"type": "image/jpeg",
|
||||
"width": 1024,
|
||||
"height": 768,
|
||||
"size": 102451,
|
||||
"thumbnail": {
|
||||
"url": "http://steveangello.com/thumbnail.jpg",
|
||||
"width": 512,
|
||||
"height": 512
|
||||
}
|
||||
}]
|
||||
*/
|
||||
});
|
||||
|
||||
// paginate results
|
||||
client.search('Steve Angello', {page: 2});
|
||||
|
||||
// search for certain size
|
||||
client.search('Steve Angello', {size: 'large'});
|
||||
42
types/google-images/index.d.ts
vendored
Normal file
42
types/google-images/index.d.ts
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
// Type definitions for google-images 2.1
|
||||
// Project: https://github.com/vadimdemedes/google-images
|
||||
// Definitions by: Dolan Miu <https://github.com/dolanmiu>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export = GoogleImages;
|
||||
|
||||
declare namespace GoogleImages {
|
||||
type SearchImageSize = "icon" | "small" | "medium" | "large" | "xlarge" | "xxlarge" | "huge";
|
||||
type SearchImageType = "clipart" | "face" | "lineart" | "news" | "photo";
|
||||
type SearchDominantColor = "black" | "blue" | "brown" | "gray" | "green" | "pink" | "purple" | "teal" | "white" | "yellow";
|
||||
type SearchColorType = "color" | "gray" | "mono";
|
||||
type SearchSafe = "high" | "medium" | "off";
|
||||
|
||||
interface SearchOptions {
|
||||
page?: number;
|
||||
size?: SearchImageSize;
|
||||
type?: SearchImageType;
|
||||
dominantColor?: SearchDominantColor;
|
||||
colorType?: SearchColorType;
|
||||
safe?: SearchSafe;
|
||||
}
|
||||
|
||||
interface Image {
|
||||
url: string;
|
||||
type: string;
|
||||
width: number;
|
||||
height: number;
|
||||
size: number;
|
||||
thumbnail: {
|
||||
url: string,
|
||||
width: number,
|
||||
height: number
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
declare class GoogleImages {
|
||||
constructor(engineId: string, apiKey: string);
|
||||
|
||||
search(searchTerm: string, options?: GoogleImages.SearchOptions): Promise<GoogleImages.Image[]>;
|
||||
}
|
||||
22
types/google-images/tsconfig.json
Normal file
22
types/google-images/tsconfig.json
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"google-images-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/google-images/tslint.json
Normal file
1
types/google-images/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user