Skip to content

Commit

Permalink
chore: update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Mar 26, 2024
1 parent da2357e commit d09baae
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 42 deletions.
53 changes: 17 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,22 @@

⇔ Conventionally and safely convert between various JavaScript data types.

<table border="0">
<tr>
<td>Supported Types</td>
<td>Features</b></td>
</tr>
<tr style="vertical-align: top;">
<td>
👍 <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer">ArrayBuffer</a><br>
👍 <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Blob">Blob</a><br>
👍 <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView">DataView</a><br>
👍 <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array">Number Array]</a><br>
👍 <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReadableStream">ReadableStream</a><br>
👍 <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String">BStringlob</a><br>
👍 <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array">Uint8Array</a><br>
</td>
<td>
✅ Type-safe usage <br>
✅ Runtime-type safety assertion <br>
✅ Auto type detection and conversion <br>
✅ Tree-shakable and compact build <br>
</td>
</tr>
</table>
## ✅ Features

- Type-safe usage
- Runtime-type safety assertion
- Auto type detection and conversion
- Tree-shakable and compact build

## 👍 Supported Types

- [ArrayBuffer][ArrayBuffer]
- [Blob][Blob]
- [DataView][DataView]
- [Number Array][Number Array]
- [ReadableStream][ReadableStream]
- [String][String]
- [Uint8Array][Uint8Array]

## Usage

Expand Down Expand Up @@ -375,43 +368,31 @@ Test if input is an instance of [Uint8Array][Uint8Array] and return `true` or `f

Convert from any value to [Uint8Array][Uint8Array]

### `detectType(input)`

### `uint8ArrayToArrayBuffer(uint8Array)`

Convert from [Uint8Array][Uint8Array] to [ArrayBuffer][ArrayBuffer]

@group Uint8Array

### `uint8ArrayToBlob(uint8Array, options?)`

Convert from [Uint8Array][Uint8Array] to [Blob][Blob]

@group Uint8Array

### `uint8ArrayToDataView(uint8Array)`

Convert from [Uint8Array][Uint8Array] to [DataView][DataView]

@group Uint8Array

### `uint8ArrayToNumberArray(uint8Array)`

Convert from [Uint8Array][Uint8Array] to [Number Array][Number Array]

@group Uint8Array

### `uint8ArrayToReadableStream(uint8Array)`

Convert from [Uint8Array][Uint8Array] to [ReadableStream][ReadableStream]

@group Uint8Array

### `uint8ArrayToString(uint8Array)`

Convert from [Uint8Array][Uint8Array] to [String][String]

@group Uint8Array
### `detectType(input)`

<!-- /automd -->

Expand Down
12 changes: 6 additions & 6 deletions src/data-types/uint8-array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ export const assertUint8Array = (input: unknown) =>

/**
* Convert from [Uint8Array][Uint8Array] to [ArrayBuffer][ArrayBuffer]
@group Uint8Array
* @group Uint8Array
*/
export function uint8ArrayToArrayBuffer(uint8Array: Uint8Array): ArrayBuffer {
return uint8Array.buffer;
}

/**
* Convert from [Uint8Array][Uint8Array] to [Blob][Blob]
@group Uint8Array
* @group Uint8Array
*/
export function uint8ArrayToBlob(
uint8Array: Uint8Array,
Expand All @@ -38,7 +38,7 @@ export function uint8ArrayToBlob(

/**
* Convert from [Uint8Array][Uint8Array] to [DataView][DataView]
@group Uint8Array
* @group Uint8Array
*/
export function uint8ArrayToDataView(uint8Array: Uint8Array): DataView {
assertUint8Array(uint8Array);
Expand All @@ -51,7 +51,7 @@ export function uint8ArrayToDataView(uint8Array: Uint8Array): DataView {

/**
* Convert from [Uint8Array][Uint8Array] to [Number Array][Number Array]
@group Uint8Array
* @group Uint8Array
*/
export function uint8ArrayToNumberArray(uint8Array: Uint8Array): number[] {
assertUint8Array(uint8Array);
Expand All @@ -60,7 +60,7 @@ export function uint8ArrayToNumberArray(uint8Array: Uint8Array): number[] {

/**
* Convert from [Uint8Array][Uint8Array] to [ReadableStream][ReadableStream]
@group Uint8Array
* @group Uint8Array
*/
export function uint8ArrayToReadableStream(
uint8Array: Uint8Array,
Expand All @@ -76,7 +76,7 @@ export function uint8ArrayToReadableStream(

/**
* Convert from [Uint8Array][Uint8Array] to [String][String]
@group Uint8Array
* @group Uint8Array
*/
export function uint8ArrayToString(uint8Array: Uint8Array): string {
assertUint8Array(uint8Array);
Expand Down

0 comments on commit d09baae

Please sign in to comment.