mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
types for downscale - uses esmoduleinterop for export default (#41493)
* types for downscale - uses esmoduleinterop for export default * umd declaration added
This commit is contained in:
parent
863519d139
commit
a1c3da38c5
19
types/downscale/downscale-tests.ts
Normal file
19
types/downscale/downscale-tests.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import downscale from 'downscale';
|
||||
|
||||
const image = new HTMLImageElement();
|
||||
const video = new HTMLVideoElement();
|
||||
const file = new File([], 'abc');
|
||||
const string = '';
|
||||
|
||||
downscale(image, 0, 0);
|
||||
downscale(video, 0, 0);
|
||||
downscale(file, 0, 0);
|
||||
downscale(string, 0, 0);
|
||||
|
||||
async function doTheTests() {
|
||||
const string_returned: string = await downscale(image, 0, 0);
|
||||
|
||||
const canvas_returned: HTMLCanvasElement = await downscale(image, 0, 0, { returnCanvas: true });
|
||||
|
||||
const blob_returned: Blob = await downscale(image, 0, 0, { returnBlob: true });
|
||||
}
|
||||
26
types/downscale/index.d.ts
vendored
Normal file
26
types/downscale/index.d.ts
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
// Type definitions for downscale 1.0
|
||||
// Project: https://github.com/ytiurin/downscale
|
||||
// Definitions by: Gabriel Soicher <https://github.com/Lunrtick>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
type ImageSource = File | HTMLImageElement | HTMLVideoElement | string;
|
||||
|
||||
interface DownscaleOptions {
|
||||
imageType?: string;
|
||||
quality?: number;
|
||||
returnBlob?: boolean;
|
||||
returnCanvas?: boolean;
|
||||
sourceX?: number;
|
||||
sourceY?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overloads that automatically type the return value based on the selected options
|
||||
*/
|
||||
declare function downscale(source: ImageSource, width: number, height: number, options?: DownscaleOptions & { returnBlob?: false; returnCanvas?: false; }): Promise<string>;
|
||||
declare function downscale(source: ImageSource, width: number, height: number, options?: DownscaleOptions & { returnBlob: true; }): Promise<Blob>;
|
||||
declare function downscale(source: ImageSource, width: number, height: number, options?: DownscaleOptions & { returnCanvas: true; }): Promise<HTMLCanvasElement>;
|
||||
|
||||
export = downscale;
|
||||
|
||||
export as namespace downscale;
|
||||
25
types/downscale/tsconfig.json
Normal file
25
types/downscale/tsconfig.json
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"DOM"
|
||||
],
|
||||
"esModuleInterop": true,
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"downscale-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/downscale/tslint.json
Normal file
1
types/downscale/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user