Skip to content

Commit

Permalink
feat: docs use typedoc, types
Browse files Browse the repository at this point in the history
  • Loading branch information
fanyushun committed Jul 19, 2024
1 parent 7986b42 commit 21c580a
Show file tree
Hide file tree
Showing 28 changed files with 658 additions and 128 deletions.
6 changes: 5 additions & 1 deletion docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { defineConfig } from 'vitepress'
import typedocSidebar from '../api/typedoc-sidebar.json'

const base = '/conversion-library/'

Expand Down Expand Up @@ -38,7 +39,10 @@ export default defineConfig({
],

sidebar: [
{ text: 'decimal conversion', link: '/api/decimal-conversion' }
{
text: 'API',
items: typedocSidebar,
},
],

socialLinks: [
Expand Down
10 changes: 0 additions & 10 deletions docs/api/decimal-conversion.md

This file was deleted.

31 changes: 31 additions & 0 deletions docs/api/functions/binaryToDecimal.md
Original file line number Diff line number Diff line change
@@ -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)
31 changes: 31 additions & 0 deletions docs/api/functions/decimalToBinary.md
Original file line number Diff line number Diff line change
@@ -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)
35 changes: 35 additions & 0 deletions docs/api/functions/decimalToOtherBase.md
Original file line number Diff line number Diff line change
@@ -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)
35 changes: 35 additions & 0 deletions docs/api/functions/otherBaseToDecimal.md
Original file line number Diff line number Diff line change
@@ -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)
35 changes: 35 additions & 0 deletions docs/api/functions/otherToTen.md
Original file line number Diff line number Diff line change
@@ -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)
35 changes: 35 additions & 0 deletions docs/api/functions/tenToOther.md
Original file line number Diff line number Diff line change
@@ -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)
31 changes: 31 additions & 0 deletions docs/api/functions/tenToTwo.md
Original file line number Diff line number Diff line change
@@ -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)
31 changes: 31 additions & 0 deletions docs/api/functions/twoToTen.md
Original file line number Diff line number Diff line change
@@ -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)
13 changes: 12 additions & 1 deletion docs/api/index.md
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
# api methods
# 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)
1 change: 1 addition & 0 deletions docs/api/typedoc-sidebar.json
Original file line number Diff line number Diff line change
@@ -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"}]}]
10 changes: 0 additions & 10 deletions index.d.ts

This file was deleted.

52 changes: 52 additions & 0 deletions lib/decimal-conversion/decimalAndBinary.ts
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -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
Expand All @@ -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
Loading

0 comments on commit 21c580a

Please # to comment.