diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index eb8813d7..9f925d6d 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -3466,7 +3466,7 @@ packages:
/@types/lodash-es@4.17.10:
resolution: {integrity: sha512-YJP+w/2khSBwbUSFdGsSqmDvmnN3cCKoPOL7Zjle6s30ZtemkkqhjVfFqGwPN7ASil5VyjE2GtyU/yqYY6mC0A==}
dependencies:
- '@types/lodash': 4.14.200
+ '@types/lodash': 4.14.192
dev: false
/@types/lodash.defaultsdeep@4.6.9:
@@ -3489,7 +3489,6 @@ packages:
/@types/lodash@4.14.192:
resolution: {integrity: sha512-km+Vyn3BYm5ytMO13k9KTp27O75rbQ0NFw+U//g+PX7VZyjCioXaRFisqSIJRECljcTv73G3i6BpglNGHgUQ5A==}
- dev: true
/@types/lodash@4.14.200:
resolution: {integrity: sha512-YI/M/4HRImtNf3pJgbF+W6FrXovqj+T+/HpENLTooK9PnkacBsDpeP3IpHab40CClUfhNmdM2WTNP2sa2dni5Q==}
@@ -4545,7 +4544,7 @@ packages:
/@vueuse/shared@10.0.0(vue@3.3.4):
resolution: {integrity: sha512-Zh3LgJqvUBWVY3SiMvXanTcfAneGbt63QPczBRDNgQ6jd/ehodO9a1lCFzaA6SWJJoI+ugVTjHFYJdoR656DVQ==}
dependencies:
- vue-demi: 0.14.5(vue@3.3.4)
+ vue-demi: 0.14.10(vue@3.3.4)
transitivePeerDependencies:
- '@vue/composition-api'
- vue
@@ -7848,6 +7847,7 @@ packages:
/jsesc@2.5.2:
resolution: {integrity: sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==}
engines: {node: '>=4'}
+ hasBin: true
/jsesc@3.0.2:
resolution: {integrity: sha512-xKqzzWXDttJuOcawBt4KnKHHIf5oQ/Cxax+0PWFG+DFDgHNAdi+TXECADI+RYiFUMmx8792xsMbbgXj4CwnP4g==}
@@ -11652,6 +11652,7 @@ packages:
/yamljs@0.3.0:
resolution: {integrity: sha512-C/FsVVhht4iPQYXOInoxUM/1ELSf9EsgKH34FofQOp6hwCPrW4vG4w5++TED3xRUo8gD7l0P1J1dLlDYzODsTQ==}
+ hasBin: true
dependencies:
argparse: 1.0.10
glob: 7.2.3
diff --git a/src/tools/hdd-calculator/hdd-calculator.service.test.ts b/src/tools/hdd-calculator/hdd-calculator.service.test.ts
new file mode 100644
index 00000000..8c6d27f2
--- /dev/null
+++ b/src/tools/hdd-calculator/hdd-calculator.service.test.ts
@@ -0,0 +1,12 @@
+import { describe, expect, it } from 'vitest';
+import { getRealSize } from './hdd-calculator.service';
+
+describe('hdd-calculator', () => {
+ it('Convert Claimed Size to Real Size', async () => {
+ expect(getRealSize(10, 'gb', 'tb')).to.equal(0.009094947017729282);
+ expect(getRealSize(10, 'pb', 'mb')).to.equal(9536743164.0625);
+ expect(getRealSize(100, 'tb', 'gb')).to.equal(93132.25746154785);
+ expect(getRealSize(1, 'pb', 'gb')).to.equal(931322.5746154785);
+ expect(getRealSize(1000, 'tb', 'gb')).to.equal(931322.5746154785);
+ });
+});
diff --git a/src/tools/hdd-calculator/hdd-calculator.service.ts b/src/tools/hdd-calculator/hdd-calculator.service.ts
new file mode 100644
index 00000000..50bdc178
--- /dev/null
+++ b/src/tools/hdd-calculator/hdd-calculator.service.ts
@@ -0,0 +1,14 @@
+const unitsConversion = {
+ kb: { dec: 1_000, bin: 1024 },
+ mb: { dec: 1_000_000, bin: 1024 * 1024 },
+ gb: { dec: 1_000_000_000, bin: 1024 * 1024 * 1024 },
+ tb: { dec: 1_000_000_000_000, bin: 1024 * 1024 * 1024 * 1024 },
+ pb: { dec: 1_000_000_000_000_000, bin: 1024 * 1024 * 1024 * 1024 * 1024 },
+};
+
+export type Units = 'kb' | 'mb' | 'gb' | 'tb' | 'pb';
+export function getRealSize(claimedCapacity: number, claimedUnit: Units, toUnit: Units) {
+ const fromUnit = unitsConversion[claimedUnit as Units];
+ const toUnitBin = unitsConversion[toUnit as Units].bin;
+ return claimedCapacity * fromUnit.dec / toUnitBin;
+};
diff --git a/src/tools/hdd-calculator/hdd-calculator.vue b/src/tools/hdd-calculator/hdd-calculator.vue
new file mode 100644
index 00000000..4c293641
--- /dev/null
+++ b/src/tools/hdd-calculator/hdd-calculator.vue
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/tools/hdd-calculator/index.ts b/src/tools/hdd-calculator/index.ts
new file mode 100644
index 00000000..8b3071ff
--- /dev/null
+++ b/src/tools/hdd-calculator/index.ts
@@ -0,0 +1,14 @@
+import { DeviceDesktop } from '@vicons/tabler';
+import { defineTool } from '../tool';
+
+export const tool = defineTool({
+ name: 'HDD calculator',
+ path: '/hdd-calculator',
+ description: 'Compute real storage space (binary) from HDD Capacity (decimal)',
+ keywords: ['hdd', 'calculator', 'size', 'conversion', 'binary', 'decimal',
+ 'gb', 'mb', 'tb',
+ 'gigabyte', 'gibibyte', 'megabyte', 'mebibyte', 'terabyte', 'tebibyte'],
+ component: () => import('./hdd-calculator.vue'),
+ icon: DeviceDesktop,
+ createdAt: new Date('2024-04-07'),
+});
diff --git a/src/tools/index.ts b/src/tools/index.ts
index 06107083..8556574a 100644
--- a/src/tools/index.ts
+++ b/src/tools/index.ts
@@ -35,6 +35,7 @@ import { tool as iso3166Searcher } from './iso-3166-searcher';
import { tool as curlConverter } from './curl-converter';
import { tool as durationCalculator } from './duration-calculator';
import { tool as folderStructureDiagram } from './folder-structure-diagram';
+import { tool as hddCalculator } from './hdd-calculator';
import { tool as pdfSignatureChecker } from './pdf-signature-checker';
import { tool as numeronymGenerator } from './numeronym-generator';
import { tool as macAddressGenerator } from './mac-address-generator';
@@ -158,6 +159,7 @@ export const toolsByCategory: ToolCategory[] = [
jsonToXml,
markdownToHtml,
currencyConverter,
+ hddCalculator,
],
},
{