Skip to content

Commit 310073a

Browse files
committed
Merge branch 'feat/gzip' into chore/all-my-stuffs
# Conflicts: # components.d.ts # package.json # pnpm-lock.yaml # src/components/TextareaCopyable.vue # src/tools/index.ts
2 parents 72364fa + ecf0eac commit 310073a

File tree

5 files changed

+112
-2
lines changed

5 files changed

+112
-2
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@
154154
"fast_array_intersect": "^1.1.0",
155155
"exif-be-gone": "^1.5.1",
156156
"event-cron-parser": "^1.0.34",
157+
"fflate": "^0.8.2",
157158
"figlet": "^1.7.0",
158159
"figue": "^1.2.0",
159160
"flatten-anything": "^4.0.1",
@@ -190,6 +191,7 @@
190191
"json2csharp": "^1.0.3",
191192
"js-base64": "^3.7.7",
192193
"ical.js": "^2.0.1",
194+
"js-base64": "^3.7.7",
193195
"json5": "^2.2.3",
194196
"jsonpath": "^1.1.1",
195197
"jsonar-mod": "^1.9.0",

pnpm-lock.yaml

Lines changed: 8 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<script setup lang="ts">
2+
import * as fflate from 'fflate';
3+
import { Base64 } from 'js-base64';
4+
import TextareaCopyable from '@/components/TextareaCopyable.vue';
5+
import { withDefaultOnError } from '@/utils/defaults';
6+
7+
const compressedInput = ref('');
8+
const decompressedOutput = computed(() => withDefaultOnError(() => {
9+
const compressedBuf = Base64.toUint8Array(compressedInput.value);
10+
return fflate.strFromU8(fflate.decompressSync(compressedBuf));
11+
}, '# invalid compressed base64 string'));
12+
13+
const rawInput = ref('');
14+
const compressedGzipOutput = computed(() => withDefaultOnError(() => Base64.fromUint8Array(fflate.gzipSync(fflate.strToU8(rawInput.value))), ''));
15+
const compressedDeflateOutput = computed(() => withDefaultOnError(() => Base64.fromUint8Array(fflate.deflateSync(fflate.strToU8(rawInput.value))), ''));
16+
const compressedZlibOutput = computed(() => withDefaultOnError(() => Base64.fromUint8Array(fflate.zlibSync(fflate.strToU8(rawInput.value))), ''));
17+
</script>
18+
19+
<template>
20+
<div style="max-width: 600px;">
21+
<c-card title="Compress string" mb-5>
22+
<c-input-text
23+
v-model:value="rawInput"
24+
multiline
25+
placeholder="Put your string here..."
26+
rows="5"
27+
label="String to compress"
28+
raw-text
29+
mb-5
30+
/>
31+
32+
<div>
33+
<h3>GZIP compressed string</h3>
34+
<TextareaCopyable
35+
:value="compressedGzipOutput"
36+
:word-wrap="true"
37+
multiline
38+
placeholder="The GZip compressed version of your string will be here"
39+
mb-5
40+
/>
41+
</div>
42+
43+
<div>
44+
<h3>Zlib compressed string</h3>
45+
<TextareaCopyable
46+
:value="compressedZlibOutput"
47+
:word-wrap="true"
48+
multiline
49+
placeholder="The Zlib compressed version of your string will be here"
50+
mb-5
51+
/>
52+
</div>
53+
54+
<div>
55+
<h3>Deflate compressed string</h3>
56+
<TextareaCopyable
57+
:value="compressedDeflateOutput"
58+
:word-wrap="true"
59+
multiline
60+
placeholder="The Deflate compressed version of your string will be here"
61+
mb-5
62+
/>
63+
</div>
64+
</c-card>
65+
66+
<c-card title="Decompress string">
67+
<c-input-text
68+
v-model:value="compressedInput"
69+
multiline
70+
placeholder="Your compressed string..."
71+
rows="5"
72+
label="Compressed string to decompress"
73+
mb-5
74+
/>
75+
76+
<div>
77+
<h3>Decompressed string</h3>
78+
<TextareaCopyable
79+
v-model:value="decompressedOutput"
80+
:word-wrap="true"
81+
multiline
82+
placeholder="The decompressed string will be here"
83+
mb-5
84+
/>
85+
</div>
86+
</c-card>
87+
</div>
88+
</template>

src/tools/gzip-converter/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { FileZip } from '@vicons/tabler';
2+
import { defineTool } from '../tool';
3+
4+
export const tool = defineTool({
5+
name: 'GZip/Deflate converter',
6+
path: '/gzip-converter',
7+
description: 'Convert text from/to gzip/deflate',
8+
keywords: ['gzip', 'deflate', 'converter'],
9+
component: () => import('./gzip-converter.vue'),
10+
icon: FileZip,
11+
createdAt: new Date('2024-03-09'),
12+
});

src/tools/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ import { tool as crcCalculator } from './crc-calculator';
7070
import { tool as ipGeoLocation } from './ip-geo-location';
7171
import { tool as ocrImage } from './ocr-image';
7272
import { tool as ansibleVaultCryptDecrypt } from './ansible-vault-crypt-decrypt';
73+
import { tool as gzipConverter } from './gzip-converter';
7374
import { tool as safelinkDecoder } from './safelink-decoder';
7475
import { tool as mongoObjectidConverter } from './mongo-objectid-converter';
7576
import { tool as removeExif } from './remove-exif';
@@ -290,6 +291,7 @@ export const toolsByCategory: ToolCategory[] = [
290291
weekNumberConverter,
291292
xmlToJson,
292293
jsonToXml,
294+
gzipConverter,
293295
],
294296
},
295297
{

0 commit comments

Comments
 (0)