mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-12 04:50:18 +00:00
Added types for module compress.js (#37675)
* Added types for module compress.js * Fixed definition of compress.js
This commit is contained in:
committed by
Pranav Senthilnathan
parent
2d6e3c5ee4
commit
235b3182f1
@@ -0,0 +1,32 @@
|
||||
import Compress = require('compress.js');
|
||||
|
||||
const compress = new Compress();
|
||||
|
||||
const uploadInput: HTMLInputElement = document.createElement('input');
|
||||
|
||||
uploadInput.type = 'file';
|
||||
|
||||
uploadInput.addEventListener(
|
||||
'change',
|
||||
event => {
|
||||
const target = event.target as HTMLInputElement;
|
||||
|
||||
if (!target.files) {
|
||||
return;
|
||||
}
|
||||
|
||||
compress.compress(Array.from(target.files), {
|
||||
size: 4,
|
||||
quality: 0.75,
|
||||
maxWidth: 1920,
|
||||
maxHeight: 1920,
|
||||
resize: true,
|
||||
});
|
||||
},
|
||||
false,
|
||||
);
|
||||
|
||||
compress.attach('#upload', {
|
||||
size: 4,
|
||||
quality: 0.75,
|
||||
});
|
||||
Vendored
+48
@@ -0,0 +1,48 @@
|
||||
// Type definitions for compress.js 1.1
|
||||
// Project: - (link to the repo is missing)
|
||||
// Definitions by: Yuri Drabik <https://github.com/yurist38>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export = Compress;
|
||||
|
||||
declare class Compress {
|
||||
attach(
|
||||
el: string,
|
||||
options: CompressOptions,
|
||||
): Promise<CompressResult[]>;
|
||||
|
||||
compress(
|
||||
files: File[],
|
||||
options: CompressOptions,
|
||||
): Promise<CompressResult[]>;
|
||||
|
||||
static convertBase64ToFile(
|
||||
base64: string,
|
||||
mime?: string,
|
||||
): File;
|
||||
}
|
||||
|
||||
interface CompressOptions {
|
||||
quality?: number;
|
||||
size?: number;
|
||||
maxWidth?: number;
|
||||
maxHeight?: number;
|
||||
resize?: boolean;
|
||||
}
|
||||
|
||||
interface CompressResult {
|
||||
data: string;
|
||||
prefix: string;
|
||||
elapsedTimeInSeconds: number;
|
||||
alt: string;
|
||||
initialSizeInMb: number;
|
||||
endSizeInMb: number;
|
||||
ext: string;
|
||||
quality: number;
|
||||
endWidthInPx: number;
|
||||
endHeightInPx: number;
|
||||
initialWidthInPx: number;
|
||||
initialHeightInPx: number;
|
||||
sizeReducedInPercent: number;
|
||||
iterations: number;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"compress.js-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user