From 21c580afa7f1af48fd7ea1199bd95e3109da5589 Mon Sep 17 00:00:00 2001 From: fanyushun Date: Fri, 19 Jul 2024 13:23:28 +0800 Subject: [PATCH] feat: docs use typedoc, types --- docs/.vitepress/config.ts | 6 +- docs/api/decimal-conversion.md | 10 -- docs/api/functions/binaryToDecimal.md | 31 ++++++ docs/api/functions/decimalToBinary.md | 31 ++++++ docs/api/functions/decimalToOtherBase.md | 35 ++++++ docs/api/functions/otherBaseToDecimal.md | 35 ++++++ docs/api/functions/otherToTen.md | 35 ++++++ docs/api/functions/tenToOther.md | 35 ++++++ docs/api/functions/tenToTwo.md | 31 ++++++ docs/api/functions/twoToTen.md | 31 ++++++ docs/api/index.md | 13 ++- docs/api/typedoc-sidebar.json | 1 + index.d.ts | 10 -- lib/decimal-conversion/decimalAndBinary.ts | 52 +++++++++ lib/decimal-conversion/decimalAndOtherBase.ts | 56 ++++++++++ package-lock.json | 105 ++++++++++++++++++ package.json | 15 ++- src/style.css | 95 ---------------- src/typescript.svg | 1 - tsconfig.json | 11 +- typedoc.json | 16 +++ .../decimal-conversion/decimalAndBinary.d.ts | 56 ++++++++++ .../decimalAndOtherBase.d.ts | 60 ++++++++++ types/decimal-conversion/index.d.ts | 2 + types/decimal-conversion/utils/index.d.ts | 1 + types/decimal-conversion/utils/radix.d.ts | 7 ++ types/main.d.ts | 1 + vite.config.ts | 4 +- 28 files changed, 658 insertions(+), 128 deletions(-) delete mode 100644 docs/api/decimal-conversion.md create mode 100644 docs/api/functions/binaryToDecimal.md create mode 100644 docs/api/functions/decimalToBinary.md create mode 100644 docs/api/functions/decimalToOtherBase.md create mode 100644 docs/api/functions/otherBaseToDecimal.md create mode 100644 docs/api/functions/otherToTen.md create mode 100644 docs/api/functions/tenToOther.md create mode 100644 docs/api/functions/tenToTwo.md create mode 100644 docs/api/functions/twoToTen.md create mode 100644 docs/api/typedoc-sidebar.json delete mode 100644 index.d.ts delete mode 100644 src/style.css delete mode 100644 src/typescript.svg create mode 100644 typedoc.json create mode 100644 types/decimal-conversion/decimalAndBinary.d.ts create mode 100644 types/decimal-conversion/decimalAndOtherBase.d.ts create mode 100644 types/decimal-conversion/index.d.ts create mode 100644 types/decimal-conversion/utils/index.d.ts create mode 100644 types/decimal-conversion/utils/radix.d.ts create mode 100644 types/main.d.ts diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index e6d81f9..8a8727d 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -1,4 +1,5 @@ import { defineConfig } from 'vitepress' +import typedocSidebar from '../api/typedoc-sidebar.json' const base = '/conversion-library/' @@ -38,7 +39,10 @@ export default defineConfig({ ], sidebar: [ - { text: 'decimal conversion', link: '/api/decimal-conversion' } + { + text: 'API', + items: typedocSidebar, + }, ], socialLinks: [ diff --git a/docs/api/decimal-conversion.md b/docs/api/decimal-conversion.md deleted file mode 100644 index fb7cf86..0000000 --- a/docs/api/decimal-conversion.md +++ /dev/null @@ -1,10 +0,0 @@ -# decimal-conversion - -## decimal and binary - -|API|description|parameter|return| -|---|---|---|---| -|`tenToTwo`|decimal to binary|`number`|`string`| -|`decimalToBinary`|decimal to binary|`number`|`string`| -|`twoToTen`|binary to decimal |`string`|`number`| -|`binaryToDecimal`|binary to decimal |`string`|`number`| diff --git a/docs/api/functions/binaryToDecimal.md b/docs/api/functions/binaryToDecimal.md new file mode 100644 index 0000000..3999e20 --- /dev/null +++ b/docs/api/functions/binaryToDecimal.md @@ -0,0 +1,31 @@ +[conversion-library](../index.md) / binaryToDecimal + +# Function: binaryToDecimal() + +```ts +function binaryToDecimal(str: string): number +``` + +binary to decimal + +## Parameters + +• **str**: `string` + +Enter a value of string type + +## Returns + +`number` + +Return the corresponding number + +## Example + +```ts +binaryToDecimal('1010') // 10 +``` + +## Defined in + +[decimalAndBinary.ts:51](https://github.com/fxss5201/conversion-library/blob/7986b4281d32fb392b20396e877bb0afeec7e5dc/lib/decimal-conversion/decimalAndBinary.ts#L51) diff --git a/docs/api/functions/decimalToBinary.md b/docs/api/functions/decimalToBinary.md new file mode 100644 index 0000000..4149949 --- /dev/null +++ b/docs/api/functions/decimalToBinary.md @@ -0,0 +1,31 @@ +[conversion-library](../index.md) / decimalToBinary + +# Function: decimalToBinary() + +```ts +function decimalToBinary(num: number): string +``` + +decimal to binary + +## Parameters + +• **num**: `number` + +Enter a value of number type + +## Returns + +`string` + +Return the corresponding binary + +## Example + +```ts +decimalToBinary(10) // '1010' +``` + +## Defined in + +[decimalAndBinary.ts:14](https://github.com/fxss5201/conversion-library/blob/7986b4281d32fb392b20396e877bb0afeec7e5dc/lib/decimal-conversion/decimalAndBinary.ts#L14) diff --git a/docs/api/functions/decimalToOtherBase.md b/docs/api/functions/decimalToOtherBase.md new file mode 100644 index 0000000..5b4e079 --- /dev/null +++ b/docs/api/functions/decimalToOtherBase.md @@ -0,0 +1,35 @@ +[conversion-library](../index.md) / decimalToOtherBase + +# Function: decimalToOtherBase() + +```ts +function decimalToOtherBase(num: number, base: number): string +``` + +decimal to other base + +## Parameters + +• **num**: `number` + +Enter a value of number type + +• **base**: `number` + +Enter a value of number type + +## Returns + +`string` + +Return the corresponding string + +## Example + +```ts +decimalToOtherBase(10, 2) // '1010' +``` + +## Defined in + +[decimalAndOtherBase.ts:17](https://github.com/fxss5201/conversion-library/blob/7986b4281d32fb392b20396e877bb0afeec7e5dc/lib/decimal-conversion/decimalAndOtherBase.ts#L17) diff --git a/docs/api/functions/otherBaseToDecimal.md b/docs/api/functions/otherBaseToDecimal.md new file mode 100644 index 0000000..5200c60 --- /dev/null +++ b/docs/api/functions/otherBaseToDecimal.md @@ -0,0 +1,35 @@ +[conversion-library](../index.md) / otherBaseToDecimal + +# Function: otherBaseToDecimal() + +```ts +function otherBaseToDecimal(str: string, base: number): number +``` + +other base to decimal + +## Parameters + +• **str**: `string` + +Enter a value of string type + +• **base**: `number` + +Enter a value of number type + +## Returns + +`number` + +Return the corresponding number + +## Example + +```ts +decimalToOtherBase('1010', 2) // 10 +``` + +## Defined in + +[decimalAndOtherBase.ts:60](https://github.com/fxss5201/conversion-library/blob/7986b4281d32fb392b20396e877bb0afeec7e5dc/lib/decimal-conversion/decimalAndOtherBase.ts#L60) diff --git a/docs/api/functions/otherToTen.md b/docs/api/functions/otherToTen.md new file mode 100644 index 0000000..91feac9 --- /dev/null +++ b/docs/api/functions/otherToTen.md @@ -0,0 +1,35 @@ +[conversion-library](../index.md) / otherToTen + +# Function: otherToTen() + +```ts +function otherToTen(str: string, base: number): number +``` + +other base to decimal + +## Parameters + +• **str**: `string` + +Enter a value of string type + +• **base**: `number` + +Enter a value of number type + +## Returns + +`number` + +Return the corresponding number + +## Example + +```ts +decimalToOtherBase('1010', 2) // 10 +``` + +## Defined in + +[decimalAndOtherBase.ts:89](https://github.com/fxss5201/conversion-library/blob/7986b4281d32fb392b20396e877bb0afeec7e5dc/lib/decimal-conversion/decimalAndOtherBase.ts#L89) diff --git a/docs/api/functions/tenToOther.md b/docs/api/functions/tenToOther.md new file mode 100644 index 0000000..8dd1c63 --- /dev/null +++ b/docs/api/functions/tenToOther.md @@ -0,0 +1,35 @@ +[conversion-library](../index.md) / tenToOther + +# Function: tenToOther() + +```ts +function tenToOther(num: number, base: number): string +``` + +decimal to other base + +## Parameters + +• **num**: `number` + +Enter a value of number type + +• **base**: `number` + +Enter a value of number type + +## Returns + +`string` + +Return the corresponding string + +## Example + +```ts +decimalToOtherBase(10, 2) // '1010' +``` + +## Defined in + +[decimalAndOtherBase.ts:44](https://github.com/fxss5201/conversion-library/blob/7986b4281d32fb392b20396e877bb0afeec7e5dc/lib/decimal-conversion/decimalAndOtherBase.ts#L44) diff --git a/docs/api/functions/tenToTwo.md b/docs/api/functions/tenToTwo.md new file mode 100644 index 0000000..02ab54e --- /dev/null +++ b/docs/api/functions/tenToTwo.md @@ -0,0 +1,31 @@ +[conversion-library](../index.md) / tenToTwo + +# Function: tenToTwo() + +```ts +function tenToTwo(num: number): string +``` + +decimal to binary + +## Parameters + +• **num**: `number` + +Enter a value of number type + +## Returns + +`string` + +Return the corresponding binary + +## Example + +```ts +decimalToBinary(10) // '1010' +``` + +## Defined in + +[decimalAndBinary.ts:36](https://github.com/fxss5201/conversion-library/blob/7986b4281d32fb392b20396e877bb0afeec7e5dc/lib/decimal-conversion/decimalAndBinary.ts#L36) diff --git a/docs/api/functions/twoToTen.md b/docs/api/functions/twoToTen.md new file mode 100644 index 0000000..78b92da --- /dev/null +++ b/docs/api/functions/twoToTen.md @@ -0,0 +1,31 @@ +[conversion-library](../index.md) / twoToTen + +# Function: twoToTen() + +```ts +function twoToTen(str: string): number +``` + +binary to decimal + +## Parameters + +• **str**: `string` + +Enter a value of string type + +## Returns + +`number` + +Return the corresponding number + +## Example + +```ts +binaryToDecimal('1010') // 10 +``` + +## Defined in + +[decimalAndBinary.ts:74](https://github.com/fxss5201/conversion-library/blob/7986b4281d32fb392b20396e877bb0afeec7e5dc/lib/decimal-conversion/decimalAndBinary.ts#L74) diff --git a/docs/api/index.md b/docs/api/index.md index ad89cf9..f827296 100644 --- a/docs/api/index.md +++ b/docs/api/index.md @@ -1 +1,12 @@ -# api methods \ No newline at end of file +# conversion-library + +## decimal-conversion + +- [binaryToDecimal](functions/binaryToDecimal.md) +- [decimalToBinary](functions/decimalToBinary.md) +- [decimalToOtherBase](functions/decimalToOtherBase.md) +- [otherBaseToDecimal](functions/otherBaseToDecimal.md) +- [otherToTen](functions/otherToTen.md) +- [tenToOther](functions/tenToOther.md) +- [tenToTwo](functions/tenToTwo.md) +- [twoToTen](functions/twoToTen.md) diff --git a/docs/api/typedoc-sidebar.json b/docs/api/typedoc-sidebar.json new file mode 100644 index 0000000..1128a87 --- /dev/null +++ b/docs/api/typedoc-sidebar.json @@ -0,0 +1 @@ +[{"text":"decimal-conversion","collapsed":true,"items":[{"text":"binaryToDecimal","link":"/api/functions/binaryToDecimal.md"},{"text":"decimalToBinary","link":"/api/functions/decimalToBinary.md"},{"text":"decimalToOtherBase","link":"/api/functions/decimalToOtherBase.md"},{"text":"otherBaseToDecimal","link":"/api/functions/otherBaseToDecimal.md"},{"text":"otherToTen","link":"/api/functions/otherToTen.md"},{"text":"tenToOther","link":"/api/functions/tenToOther.md"},{"text":"tenToTwo","link":"/api/functions/tenToTwo.md"},{"text":"twoToTen","link":"/api/functions/twoToTen.md"}]}] \ No newline at end of file diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index b3836b1..0000000 --- a/index.d.ts +++ /dev/null @@ -1,10 +0,0 @@ -declare namespace conversionLibrary { - export function tenToTwo (num: number): string - export function decimalToBinary (num: number): string - export function twoToTen (num: number): string - export function binaryToDecimal (num: number): string - export function tenToOther (num: number, base: number): string - export function decimalToOtherBase (num: number, base: number): string - export function otherToTen (str: string, base: number): number - export function otherBaseToDecimal (str: string, base: number): number -} diff --git a/lib/decimal-conversion/decimalAndBinary.ts b/lib/decimal-conversion/decimalAndBinary.ts index c34554a..986a863 100644 --- a/lib/decimal-conversion/decimalAndBinary.ts +++ b/lib/decimal-conversion/decimalAndBinary.ts @@ -1,3 +1,16 @@ +/** + * decimal to binary + * + * @group decimal-conversion + * + * @param num - Enter a value of number type + * @returns Return the corresponding binary + * + * @example + * ```ts + * decimalToBinary(10) // '1010' + * ``` + */ export function decimalToBinary (num: number): string { let res = '' while (num > 0) { @@ -7,8 +20,34 @@ export function decimalToBinary (num: number): string { return res } +/** + * decimal to binary + * + * @group decimal-conversion + * + * @param num - Enter a value of number type + * @returns Return the corresponding binary + * + * @example + * ```ts + * tenToTwo(10) // '1010' + * ``` + */ export const tenToTwo = decimalToBinary +/** + * binary to decimal + * + * @group decimal-conversion + * + * @param str - Enter a value of string type + * @returns Return the corresponding number + * + * @example + * ```ts + * binaryToDecimal('1010') // 10 + * ``` + */ export function binaryToDecimal (str: string): number { let res = 0 let digit = 0 @@ -19,4 +58,17 @@ export function binaryToDecimal (str: string): number { return res } +/** + * binary to decimal + * + * @group decimal-conversion + * + * @param str - Enter a value of string type + * @returns Return the corresponding number + * + * @example + * ```ts + * twoToTen('1010') // 10 + * ``` + */ export const twoToTen = binaryToDecimal diff --git a/lib/decimal-conversion/decimalAndOtherBase.ts b/lib/decimal-conversion/decimalAndOtherBase.ts index 0a802ee..42447e1 100644 --- a/lib/decimal-conversion/decimalAndOtherBase.ts +++ b/lib/decimal-conversion/decimalAndOtherBase.ts @@ -1,5 +1,19 @@ import { getMapNumberToString, getMapStringToNumber } from "./utils" +/** + * decimal to other base + * + * @group decimal-conversion + * + * @param num - Enter a value of number type + * @param base - Enter a value of number type + * @returns Return the corresponding string + * + * @example + * ```ts + * decimalToOtherBase(10, 2) // '1010' + * ``` + */ export function decimalToOtherBase (num: number, base: number): string { if (base === 10 || base > 36 || base < 2) return String(num) const numToStr = getMapNumberToString(base) @@ -13,8 +27,36 @@ export function decimalToOtherBase (num: number, base: number): string { return res } +/** + * decimal to other base + * + * @group decimal-conversion + * + * @param num - Enter a value of number type + * @param base - Enter a value of number type + * @returns Return the corresponding string + * + * @example + * ```ts + * tenToOther(10, 2) // '1010' + * ``` + */ export const tenToOther = decimalToOtherBase +/** + * other base to decimal + * + * @group decimal-conversion + * + * @param str - Enter a value of string type + * @param base - Enter a value of number type + * @returns Return the corresponding number + * + * @example + * ```ts + * decimalToOtherBase('1010', 2) // 10 + * ``` + */ export function otherBaseToDecimal (str: string, base: number): number { if (base === 10 || base > 36 || base < 2) return Number(str) str = str.toLowerCase() @@ -30,4 +72,18 @@ export function otherBaseToDecimal (str: string, base: number): number { return res } +/** + * other base to decimal + * + * @group decimal-conversion + * + * @param str - Enter a value of string type + * @param base - Enter a value of number type + * @returns Return the corresponding number + * + * @example + * ```ts + * otherToTen('1010', 2) // 10 + * ``` + */ export const otherToTen = otherBaseToDecimal diff --git a/package-lock.json b/package-lock.json index de5a4a0..bc348e9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,6 +15,9 @@ "coveralls": "^3.1.1", "cz-git": "^1.9.3", "czg": "^1.9.3", + "typedoc": "^0.26.4", + "typedoc-plugin-markdown": "^4.2.1", + "typedoc-vitepress-theme": "^1.0.1", "typescript": "^5.4.5", "vite": "^5.2.10", "vitepress": "^1.3.1", @@ -3955,6 +3958,15 @@ "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==", "dev": true }, + "node_modules/linkify-it": { + "version": "5.0.0", + "resolved": "https://registry.npmmirror.com/linkify-it/-/linkify-it-5.0.0.tgz", + "integrity": "sha512-5aHCbzQRADcdP+ATqnDuhhJ/MRIqDkZX5pyjFHRRysS8vZ5AbqGEoFIb6pYHPZ+L/OC2Lc+xT8uHVVR5CAK/wQ==", + "dev": true, + "dependencies": { + "uc.micro": "^2.0.0" + } + }, "node_modules/load-json-file": { "version": "4.0.0", "resolved": "https://registry.npmmirror.com/load-json-file/-/load-json-file-4.0.0.tgz", @@ -4030,6 +4042,12 @@ "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", "dev": true }, + "node_modules/lunr": { + "version": "2.3.9", + "resolved": "https://registry.npmmirror.com/lunr/-/lunr-2.3.9.tgz", + "integrity": "sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==", + "dev": true + }, "node_modules/magic-string": { "version": "0.30.10", "resolved": "https://registry.npmmirror.com/magic-string/-/magic-string-0.30.10.tgz", @@ -4083,12 +4101,41 @@ "integrity": "sha512-1I+1qpDt4idfgLQG+BNWmrqku+7/2bi5nLf4YwF8y8zXvmfiTBY3PV3ZibfrjBueCByROpuBjLLFCajqkgYoLQ==", "dev": true }, + "node_modules/markdown-it": { + "version": "14.1.0", + "resolved": "https://registry.npmmirror.com/markdown-it/-/markdown-it-14.1.0.tgz", + "integrity": "sha512-a54IwgWPaeBCAAsv13YgmALOF1elABB08FxO9i+r4VFk5Vl4pKokRPeX8u5TCgSsPi6ec1otfLjdOpVcgbpshg==", + "dev": true, + "dependencies": { + "argparse": "^2.0.1", + "entities": "^4.4.0", + "linkify-it": "^5.0.0", + "mdurl": "^2.0.0", + "punycode.js": "^2.3.1", + "uc.micro": "^2.1.0" + }, + "bin": { + "markdown-it": "bin/markdown-it.mjs" + } + }, + "node_modules/markdown-it/node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmmirror.com/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true + }, "node_modules/mdn-data": { "version": "2.0.30", "resolved": "https://registry.npmmirror.com/mdn-data/-/mdn-data-2.0.30.tgz", "integrity": "sha512-GaqWWShW4kv/G9IEucWScBx9G1/vsFZZJUO+tD26M8J8z3Kw5RDQjaoZe03YAClgeS/SWPOcb4nkFBTEi5DUEA==", "dev": true }, + "node_modules/mdurl": { + "version": "2.0.0", + "resolved": "https://registry.npmmirror.com/mdurl/-/mdurl-2.0.0.tgz", + "integrity": "sha512-Lf+9+2r+Tdp5wXDXC4PcIBjTDtq4UKjCPMQhKIuzpJNW0b96kVqSwW0bT7FhRSfmAiFYgP+SCRvdrDozfh0U5w==", + "dev": true + }, "node_modules/meow": { "version": "8.1.2", "resolved": "https://registry.npmmirror.com/meow/-/meow-8.1.2.tgz", @@ -4748,6 +4795,15 @@ "node": ">=6" } }, + "node_modules/punycode.js": { + "version": "2.3.1", + "resolved": "https://registry.npmmirror.com/punycode.js/-/punycode.js-2.3.1.tgz", + "integrity": "sha512-uxFIHU0YlHYhDQtV4R9J6a52SLx28BCjT+4ieh7IGbgwVJWO+km431c4yRlREUAsAmt/uMjQUyQHNEPf0M39CA==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/q": { "version": "1.5.1", "resolved": "https://registry.npmmirror.com/q/-/q-1.5.1.tgz", @@ -5745,6 +5801,49 @@ "integrity": "sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==", "dev": true }, + "node_modules/typedoc": { + "version": "0.26.4", + "resolved": "https://registry.npmmirror.com/typedoc/-/typedoc-0.26.4.tgz", + "integrity": "sha512-FlW6HpvULDKgc3rK04V+nbFyXogPV88hurarDPOjuuB5HAwuAlrCMQ5NeH7Zt68a/ikOKu6Z/0hFXAeC9xPccQ==", + "dev": true, + "dependencies": { + "lunr": "^2.3.9", + "markdown-it": "^14.1.0", + "minimatch": "^9.0.5", + "shiki": "^1.9.1", + "yaml": "^2.4.5" + }, + "bin": { + "typedoc": "bin/typedoc" + }, + "engines": { + "node": ">= 18" + }, + "peerDependencies": { + "typescript": "4.6.x || 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x || 5.2.x || 5.3.x || 5.4.x || 5.5.x" + } + }, + "node_modules/typedoc-plugin-markdown": { + "version": "4.2.1", + "resolved": "https://registry.npmmirror.com/typedoc-plugin-markdown/-/typedoc-plugin-markdown-4.2.1.tgz", + "integrity": "sha512-7hQt/1WaW/VI4+x3sxwcCGsEylP1E1GvF6OTTELK5sfTEp6AeK+83jkCOgZGp1pI2DiOammMYQMnxxOny9TKsQ==", + "dev": true, + "engines": { + "node": ">= 18" + }, + "peerDependencies": { + "typedoc": "0.26.x" + } + }, + "node_modules/typedoc-vitepress-theme": { + "version": "1.0.1", + "resolved": "https://registry.npmmirror.com/typedoc-vitepress-theme/-/typedoc-vitepress-theme-1.0.1.tgz", + "integrity": "sha512-pnpgzSQRaR9QLMl3it/tjq7vlV+eeUzKa22w/xF6ZUdAcYdmeag13kuA6EKfU7/kkIkJ/qsu1GPd3OcIC36Hlw==", + "dev": true, + "peerDependencies": { + "typedoc-plugin-markdown": ">=4.1.0" + } + }, "node_modules/typescript": { "version": "5.5.3", "integrity": "sha512-/hreyEujaB0w76zKo6717l3L0o/qEUtRgdvUBvlkhoWeOVMjMuHNHk0BRBzikzuGDqNmPQbg5ifMEqsHLiIUcQ==", @@ -5757,6 +5856,12 @@ "node": ">=14.17" } }, + "node_modules/uc.micro": { + "version": "2.1.0", + "resolved": "https://registry.npmmirror.com/uc.micro/-/uc.micro-2.1.0.tgz", + "integrity": "sha512-ARDJmphmdvUk6Glw7y9DQ2bFkKBHwQHLi2lsaH6PPmz/Ka9sFOBsBluozhDltWmnv9u/cF6Rt87znRTPV+yp/A==", + "dev": true + }, "node_modules/uglify-js": { "version": "3.19.0", "resolved": "https://registry.npmmirror.com/uglify-js/-/uglify-js-3.19.0.tgz", diff --git a/package.json b/package.json index 56f7570..a7ce126 100644 --- a/package.json +++ b/package.json @@ -16,22 +16,24 @@ "type": "module", "files": [ "dist", - "index.d.ts" + "types" ], "main": "./dist/conversion-library.umd.cjs", "module": "./dist/conversion-library.js", - "types": "./index.d.ts", + "types": "./types/main.d.ts", "exports": { - "types": "./index.d.ts", + "types": "./types/main.d.ts", "import": "./dist/conversion-library.js", "require": "./dist/conversion-library.umd.cjs" }, "scripts": { "dev": "vite", "test": "vitest --ui", + "type": "tsc", "build": "tsc && vite build", - "docs:dev": "vitepress dev docs", - "docs:build": "vitepress build docs", + "predocs": "typedoc", + "docs:dev": "typedoc && vitepress dev docs", + "docs:build": "typedoc && vitepress build docs", "docs:preview": "vitepress preview docs", "release": "commit-and-tag-version", "cz": "czg" @@ -46,6 +48,9 @@ "coveralls": "^3.1.1", "cz-git": "^1.9.3", "czg": "^1.9.3", + "typedoc": "^0.26.4", + "typedoc-plugin-markdown": "^4.2.1", + "typedoc-vitepress-theme": "^1.0.1", "typescript": "^5.4.5", "vite": "^5.2.10", "vitepress": "^1.3.1", diff --git a/src/style.css b/src/style.css deleted file mode 100644 index 2308c34..0000000 --- a/src/style.css +++ /dev/null @@ -1,95 +0,0 @@ -:root { - font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; - line-height: 1.5; - font-weight: 400; - - color-scheme: light dark; - color: rgba(255, 255, 255, 0.87); - background-color: #242424; - - font-synthesis: none; - text-rendering: optimizeLegibility; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - -a { - font-weight: 500; - color: #646cff; - text-decoration: inherit; -} -a:hover { - color: #535bf2; -} - -body { - margin: 0; - display: flex; - place-items: center; - min-width: 320px; - min-height: 100vh; -} - -h1 { - font-size: 3.2em; - line-height: 1.1; -} - -#app { - max-width: 1280px; - margin: 0 auto; - padding: 2rem; - text-align: center; -} - -.logo { - height: 6em; - padding: 1.5em; - will-change: filter; -} -.logo:hover { - filter: drop-shadow(0 0 2em #646cffaa); -} -.logo.vanilla:hover { - filter: drop-shadow(0 0 2em #3178c6aa); -} - -.card { - padding: 2em; -} - -.read-the-docs { - color: #888; -} - -button { - border-radius: 8px; - border: 1px solid transparent; - padding: 0.6em 1.2em; - font-size: 1em; - font-weight: 500; - font-family: inherit; - background-color: #1a1a1a; - cursor: pointer; - transition: border-color 0.25s; -} -button:hover { - border-color: #646cff; -} -button:focus, -button:focus-visible { - outline: 4px auto -webkit-focus-ring-color; -} - -@media (prefers-color-scheme: light) { - :root { - color: #213547; - background-color: #ffffff; - } - a:hover { - color: #747bff; - } - button { - background-color: #f9f9f9; - } -} diff --git a/src/typescript.svg b/src/typescript.svg deleted file mode 100644 index d91c910..0000000 --- a/src/typescript.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 8b42f77..23e462f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,13 +11,18 @@ "allowImportingTsExtensions": true, "resolveJsonModule": true, "isolatedModules": true, - "noEmit": true, /* Linting */ "strict": true, "noUnusedLocals": true, "noUnusedParameters": true, - "noFallthroughCasesInSwitch": true + "noFallthroughCasesInSwitch": true, + "noEmit": true, + // "emitDeclarationOnly": true, + // "declaration": true, + // "declarationDir": "types" }, - "include": ["src"] + "include": ["src"], + // "include": ["lib"], + // "exclude": ["**/*.test.ts"] } diff --git a/typedoc.json b/typedoc.json new file mode 100644 index 0000000..436499c --- /dev/null +++ b/typedoc.json @@ -0,0 +1,16 @@ +{ + "plugin": ["typedoc-plugin-markdown", "typedoc-vitepress-theme"], + "entryPoints": ["./lib/main.ts"], + "out": "./docs/api", + "docsRoot": "./docs", + "outputFileStrategy": "members", + "sidebar": { + "autoConfiguration": true, + "format": "vitepress", + "pretty": false, + "collapsed": true + }, + "useCodeBlocks": true, + "expandObjects": true, + "expandParameters": true +} \ No newline at end of file diff --git a/types/decimal-conversion/decimalAndBinary.d.ts b/types/decimal-conversion/decimalAndBinary.d.ts new file mode 100644 index 0000000..72a9054 --- /dev/null +++ b/types/decimal-conversion/decimalAndBinary.d.ts @@ -0,0 +1,56 @@ +/** + * decimal to binary + * + * @group decimal-conversion + * + * @param num - Enter a value of number type + * @returns Return the corresponding binary + * + * @example + * ```ts + * decimalToBinary(10) // '1010' + * ``` + */ +export declare function decimalToBinary(num: number): string; +/** + * decimal to binary + * + * @group decimal-conversion + * + * @param num - Enter a value of number type + * @returns Return the corresponding binary + * + * @example + * ```ts + * tenToTwo(10) // '1010' + * ``` + */ +export declare const tenToTwo: typeof decimalToBinary; +/** + * binary to decimal + * + * @group decimal-conversion + * + * @param str - Enter a value of string type + * @returns Return the corresponding number + * + * @example + * ```ts + * binaryToDecimal('1010') // 10 + * ``` + */ +export declare function binaryToDecimal(str: string): number; +/** + * binary to decimal + * + * @group decimal-conversion + * + * @param str - Enter a value of string type + * @returns Return the corresponding number + * + * @example + * ```ts + * twoToTen('1010') // 10 + * ``` + */ +export declare const twoToTen: typeof binaryToDecimal; diff --git a/types/decimal-conversion/decimalAndOtherBase.d.ts b/types/decimal-conversion/decimalAndOtherBase.d.ts new file mode 100644 index 0000000..9ff616d --- /dev/null +++ b/types/decimal-conversion/decimalAndOtherBase.d.ts @@ -0,0 +1,60 @@ +/** + * decimal to other base + * + * @group decimal-conversion + * + * @param num - Enter a value of number type + * @param base - Enter a value of number type + * @returns Return the corresponding string + * + * @example + * ```ts + * decimalToOtherBase(10, 2) // '1010' + * ``` + */ +export declare function decimalToOtherBase(num: number, base: number): string; +/** + * decimal to other base + * + * @group decimal-conversion + * + * @param num - Enter a value of number type + * @param base - Enter a value of number type + * @returns Return the corresponding string + * + * @example + * ```ts + * tenToOther(10, 2) // '1010' + * ``` + */ +export declare const tenToOther: typeof decimalToOtherBase; +/** + * other base to decimal + * + * @group decimal-conversion + * + * @param str - Enter a value of string type + * @param base - Enter a value of number type + * @returns Return the corresponding number + * + * @example + * ```ts + * decimalToOtherBase('1010', 2) // 10 + * ``` + */ +export declare function otherBaseToDecimal(str: string, base: number): number; +/** + * other base to decimal + * + * @group decimal-conversion + * + * @param str - Enter a value of string type + * @param base - Enter a value of number type + * @returns Return the corresponding number + * + * @example + * ```ts + * otherToTen('1010', 2) // 10 + * ``` + */ +export declare const otherToTen: typeof otherBaseToDecimal; diff --git a/types/decimal-conversion/index.d.ts b/types/decimal-conversion/index.d.ts new file mode 100644 index 0000000..6d5e69b --- /dev/null +++ b/types/decimal-conversion/index.d.ts @@ -0,0 +1,2 @@ +export * from './decimalAndOtherBase'; +export * from './decimalAndBinary'; diff --git a/types/decimal-conversion/utils/index.d.ts b/types/decimal-conversion/utils/index.d.ts new file mode 100644 index 0000000..bde816b --- /dev/null +++ b/types/decimal-conversion/utils/index.d.ts @@ -0,0 +1 @@ +export * from './radix'; diff --git a/types/decimal-conversion/utils/radix.d.ts b/types/decimal-conversion/utils/radix.d.ts new file mode 100644 index 0000000..53bfcdd --- /dev/null +++ b/types/decimal-conversion/utils/radix.d.ts @@ -0,0 +1,7 @@ +export declare function leftFillZero(str: string, length: number): string; +export declare function getMapNumberToString(base: number): { + [key: string]: string; +}; +export declare function getMapStringToNumber(base: number): { + [key: string]: string; +}; diff --git a/types/main.d.ts b/types/main.d.ts new file mode 100644 index 0000000..2a9c3ec --- /dev/null +++ b/types/main.d.ts @@ -0,0 +1 @@ +export * from './decimal-conversion'; diff --git a/vite.config.ts b/vite.config.ts index 30adace..5cde1ef 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -6,8 +6,8 @@ export default defineConfig({ build: { lib: { entry: './lib/main.ts', - name: 'Counter', - fileName: 'counter' + name: 'conversion-library', + fileName: 'conversion-library' } }, test: {