Skip to content

Commit

Permalink
♻️ (VueCroppieComponent.js): Refactor get and result methods to simpl…
Browse files Browse the repository at this point in the history
…ify code and improve readability

The get and result methods in VueCroppieComponent.js have been refactored to simplify the code and improve readability. The if-else statements have been simplified to reduce unnecessary nesting and improve the flow of the code. This makes the code easier to understand and maintain.
  • Loading branch information
jofftiquez committed May 20, 2024
1 parent b5b3435 commit 6fcf468
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions src/VueCroppieComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
Expand Down

0 comments on commit 6fcf468

Please sign in to comment.