Skip to content

Commit 1040e1d

Browse files
committed
rename functions
1 parent 50969ae commit 1040e1d

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

src/App.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import { useFileDataStore } from './stores/fileData';
66
import { storeToRefs } from 'pinia';
77
import type { FileObj } from './types/file';
88
import { computed, ref, watch } from 'vue';
9-
import { useImageCompression } from './composables/useImageCompression';
10-
import { useZipCompression } from './composables/useZipCompression';
9+
import { compressFile } from './functions/imageCompression';
10+
import { comressToZip } from './functions/zipCompression';
1111
import { useI18n } from './hooks/useI18n';
1212
1313
const { t } = useI18n();
@@ -22,7 +22,7 @@ const anyUncompressed = computed(() => files.value.some((file) => !file.isCompre
2222
2323
async function editFileObj(fileObj: FileObj) {
2424
try {
25-
const compressedFile = await useImageCompression(fileObj.file);
25+
const compressedFile = await compressFile(fileObj.file);
2626
const item = files.value.find((item) => item.id === fileObj.id);
2727
if (!item) return;
2828
item.file = compressedFile;
@@ -50,7 +50,7 @@ function removeItem(file: FileObj) {
5050
watch(anyUncompressed, async (newVal) => {
5151
if (files.value.length && !newVal) {
5252
isZipCompressing.value = true;
53-
zipData.value = await useZipCompression();
53+
zipData.value = await comressToZip();
5454
isZipCompressing.value = false;
5555
}
5656
});

src/composables/useImageCompression.ts renamed to src/functions/imageCompression.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { compressImage, imageTypes } from 'simple-image-compressor';
22
import { maxSize } from '@/variables/constants';
33

4-
export async function useImageCompression(file: File, quality: number = 1): Promise<File> {
4+
export async function compressFile(file: File, quality: number = 1): Promise<File> {
55
if (file.size < maxSize) return file; // if below 10 MB, don't do anything
66
const res = await compressImage(file, {
77
quality,
88
type: imageTypes.JPEG,
99
});
1010
const lowerQuality = quality - 0.01; // NoSonar reduce quality by 1%;
11-
if (res.size > maxSize) return await useImageCompression(file, lowerQuality); // compress original file with lower quality setting to avoid double compression
11+
if (res.size > maxSize) return await compressFile(file, lowerQuality); // compress original file with lower quality setting to avoid double compression
1212
const fileName = file.name.split('.').slice(0, -1).join('.');
1313
const newFileName = fileName + '-min.jpg';
1414
return new File([res], newFileName, { type: imageTypes.JPEG });

src/composables/useZipCompression.ts renamed to src/functions/zipCompression.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import JSZip from 'jszip';
22
import { storeToRefs } from 'pinia';
33
import { useFileDataStore } from '@/stores/fileData';
44

5-
export async function useZipCompression(): Promise<string> {
5+
export async function comressToZip(): Promise<string> {
66
const zip = new JSZip();
77

88
const fileDataStore = useFileDataStore();

0 commit comments

Comments
 (0)