diff --git a/components.d.ts b/components.d.ts index 89f41f80..078bf09b 100644 --- a/components.d.ts +++ b/components.d.ts @@ -129,22 +129,15 @@ declare module '@vue/runtime-core' { MetaTagGenerator: typeof import('./src/tools/meta-tag-generator/meta-tag-generator.vue')['default'] MimeTypes: typeof import('./src/tools/mime-types/mime-types.vue')['default'] NavbarButtons: typeof import('./src/components/NavbarButtons.vue')['default'] - NCode: typeof import('naive-ui')['NCode'] NCollapseTransition: typeof import('naive-ui')['NCollapseTransition'] NConfigProvider: typeof import('naive-ui')['NConfigProvider'] NEllipsis: typeof import('naive-ui')['NEllipsis'] - NForm: typeof import('naive-ui')['NForm'] - NFormItem: typeof import('naive-ui')['NFormItem'] NH1: typeof import('naive-ui')['NH1'] NH3: typeof import('naive-ui')['NH3'] NIcon: typeof import('naive-ui')['NIcon'] - NInputNumber: typeof import('naive-ui')['NInputNumber'] NLayout: typeof import('naive-ui')['NLayout'] NLayoutSider: typeof import('naive-ui')['NLayoutSider'] NMenu: typeof import('naive-ui')['NMenu'] - NScrollbar: typeof import('naive-ui')['NScrollbar'] - NSlider: typeof import('naive-ui')['NSlider'] - NSwitch: typeof import('naive-ui')['NSwitch'] NumeronymGenerator: typeof import('./src/tools/numeronym-generator/numeronym-generator.vue')['default'] OtpCodeGeneratorAndValidator: typeof import('./src/tools/otp-code-generator-and-validator/otp-code-generator-and-validator.vue')['default'] PasswordStrengthAnalyser: typeof import('./src/tools/password-strength-analyser/password-strength-analyser.vue')['default'] @@ -161,6 +154,7 @@ declare module '@vue/runtime-core' { RsaKeyPairGenerator: typeof import('./src/tools/rsa-key-pair-generator/rsa-key-pair-generator.vue')['default'] SafelinkDecoder: typeof import('./src/tools/safelink-decoder/safelink-decoder.vue')['default'] SlugifyString: typeof import('./src/tools/slugify-string/slugify-string.vue')['default'] + SmartRawConverter: typeof import('./src/tools/smart-raw-converter/smart-raw-converter.vue')['default'] SpanCopyable: typeof import('./src/components/SpanCopyable.vue')['default'] SqlPrettify: typeof import('./src/tools/sql-prettify/sql-prettify.vue')['default'] StringObfuscator: typeof import('./src/tools/string-obfuscator/string-obfuscator.vue')['default'] diff --git a/src/tools/index.ts b/src/tools/index.ts index b4c161ef..e1b10081 100644 --- a/src/tools/index.ts +++ b/src/tools/index.ts @@ -2,6 +2,7 @@ import { tool as base64FileConverter } from './base64-file-converter'; import { tool as base64StringConverter } from './base64-string-converter'; import { tool as basicAuthGenerator } from './basic-auth-generator'; import { tool as emailNormalizer } from './email-normalizer'; +import { tool as smartRawConverter } from './smart-raw-converter'; import { tool as asciiTextDrawer } from './ascii-text-drawer'; @@ -112,6 +113,7 @@ export const toolsByCategory: ToolCategory[] = [ tomlToYaml, xmlToJson, jsonToXml, + smartRawConverter, ], }, { diff --git a/src/tools/smart-raw-converter/index.ts b/src/tools/smart-raw-converter/index.ts new file mode 100644 index 00000000..eeb8c78b --- /dev/null +++ b/src/tools/smart-raw-converter/index.ts @@ -0,0 +1,12 @@ +import { Disc } from '@vicons/tabler'; +import { defineTool } from '../tool'; + +export const tool = defineTool({ + name: 'SMART Raw Converter', + path: '/smart-raw-converter', + description: 'Convert SMART Raw values to human readable', + keywords: ['smart', 'raw', 'converter'], + component: () => import('./smart-raw-converter.vue'), + icon: Disc, + createdAt: new Date('2024-07-14'), +}); diff --git a/src/tools/smart-raw-converter/smart-raw-converter.service.test.ts b/src/tools/smart-raw-converter/smart-raw-converter.service.test.ts new file mode 100644 index 00000000..4d3d92d7 --- /dev/null +++ b/src/tools/smart-raw-converter/smart-raw-converter.service.test.ts @@ -0,0 +1,13 @@ +import { describe, expect, it } from 'vitest'; +import { getSmartValue } from './smart-raw-converter.service'; + +describe('smart-raw-converter', () => { + describe('getSmartValue', () => { + it('to return correct values', () => { + expect(getSmartValue(8590065666)).to.deep.eq({ + errors: 2, + operations: 131074, + }); + }); + }); +}); diff --git a/src/tools/smart-raw-converter/smart-raw-converter.service.ts b/src/tools/smart-raw-converter/smart-raw-converter.service.ts new file mode 100644 index 00000000..308a76f3 --- /dev/null +++ b/src/tools/smart-raw-converter/smart-raw-converter.service.ts @@ -0,0 +1,14 @@ +export function getSmartValue(raw: number) { + const n = raw.toString(2); + let bin = ''; + for (let i = 0; i < 64 - n.length; ++i) { + bin += '0'; + } + bin += n; + const lo = Number.parseInt(bin.slice(0, 32), 2); + const hi = Number.parseInt(bin.slice(32), 2); + return { + errors: lo, + operations: hi, + }; +} diff --git a/src/tools/smart-raw-converter/smart-raw-converter.vue b/src/tools/smart-raw-converter/smart-raw-converter.vue new file mode 100644 index 00000000..b52f36c9 --- /dev/null +++ b/src/tools/smart-raw-converter/smart-raw-converter.vue @@ -0,0 +1,44 @@ + + +