From 0b1244d71f6124105b1cbbd383d5295d4372f175 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E9=BA=9F?= Date: Thu, 7 Apr 2022 19:23:08 +0800 Subject: [PATCH 1/2] feat: add definition for typescript --- index.d.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..4037e00 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,20 @@ +export interface JSImageCompressorOptions { + file: File; + quality?: number; + mimeType?: string; + maxWidth?: number; + maxHeight?: number; + width?: number; + height?: number; + minWidth?: number; + minHeight?: number; + convertSize?: number; + loose?: boolean; + redressOrientation?: boolean; + beforeCompress?: (file: T) => void; + success?: (file: T) => void; + error?: (msg: string) => void; +} +export default class JSImageCompressor { + constructor(options: JSImageCompressorOptions) {} +} From 60634dc1f73afb9c4067bc2b3eb039d8f7d73580 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E9=BA=9F?= Date: Thu, 7 Apr 2022 19:26:00 +0800 Subject: [PATCH 2/2] fix: add bind this to avoid this undefined in error method --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index e86fabb..b3fd849 100644 --- a/src/index.js +++ b/src/index.js @@ -98,7 +98,7 @@ _proto.init = function () { _this.rendCanvas() } }, - _this.error + _this.error.bind(_this) ) }