From 6fcf4686731bab70fc29aded96147754fc701e53 Mon Sep 17 00:00:00 2001 From: Joff Tiquez Date: Mon, 20 May 2024 18:06:32 +0800 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20(VueCroppieComponent.js):?= =?UTF-8?q?=20Refactor=20get=20and=20result=20methods=20to=20simplify=20co?= =?UTF-8?q?de=20and=20improve=20readability=20The=20get=20and=20result=20m?= =?UTF-8?q?ethods=20in=20VueCroppieComponent.js=20have=20been=20refactored?= =?UTF-8?q?=20to=20simplify=20the=20code=20and=20improve=20readability.=20?= =?UTF-8?q?The=20if-else=20statements=20have=20been=20simplified=20to=20re?= =?UTF-8?q?duce=20unnecessary=20nesting=20and=20improve=20the=20flow=20of?= =?UTF-8?q?=20the=20code.=20This=20makes=20the=20code=20easier=20to=20unde?= =?UTF-8?q?rstand=20and=20maintain.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/VueCroppieComponent.js | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/VueCroppieComponent.js b/src/VueCroppieComponent.js index 8aea817..289a62b 100644 --- a/src/VueCroppieComponent.js +++ b/src/VueCroppieComponent.js @@ -98,11 +98,8 @@ export default { this.croppie.destroy(); }, get(cb) { - if(cb){ - cb(this.croppie.get()) - } else { - return this.croppie.get() - } + if (!cb) return this.croppie.get(); + cb(this.croppie.get()); }, rotate(angle) { this.croppie.rotate(angle); @@ -112,14 +109,14 @@ export default { }, result(options, cb) { if(!options) options = {type: 'base64'} - return this.croppie.result(options).then(output => { - if(!cb) { - this.$emit('result', output); - } else { - cb(output); - } - return output; - }); + return this.croppie.result(options).then(output => { + if(!cb) { + this.$emit('result', output); + } else { + cb(output); + } + return output; + }); }, refresh() { this.croppie.destroy();