Skip to content

Commit

Permalink
Blob arrayBuffer base64 file blobUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
saqqdy committed Oct 27, 2023
1 parent eee2a8b commit 56de101
Show file tree
Hide file tree
Showing 17 changed files with 518 additions and 1 deletion.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Change logs

## 2023.10.27 v5.13.0

1. new `arrayBufferToBase64` function, see: [arrayBufferToBase64](https://github.com/saqqdy/js-cool#arraybuffertobase64)
2. new `arrayBufferToBlob` function, see: [arrayBufferToBlob](https://github.com/saqqdy/js-cool#arraybuffertoblob)
3. new `base64ToArrayBuffer` function, see: [base64ToArrayBuffer](https://github.com/saqqdy/js-cool#base64toarraybuffer)
4. new `base64ToBlob` function, see: [base64ToBlob](https://github.com/saqqdy/js-cool#base64toblob)
5. new `base64ToFile` function, see: [base64ToFile](https://github.com/saqqdy/js-cool#base64tofile)
6. new `blobToArrayBuffer` function, see: [blobToArrayBuffer](https://github.com/saqqdy/js-cool#blobtoarraybuffer)
7. new `blobToBase64` function, see: [blobToBase64](https://github.com/saqqdy/js-cool#blobtobase64)
8. new `blobToUrl` function, see: [blobToUrl](https://github.com/saqqdy/js-cool#blobtourl)
9. new `fileToBase64` function, see: [fileToBase64](https://github.com/saqqdy/js-cool#filetobase64)
10. new `svgToBlob` function, see: [svgToBlob](https://github.com/saqqdy/js-cool#svgtoblob)
11. new `urlToBlob` function, see: [urlToBlob](https://github.com/saqqdy/js-cool#urltoblob)

## 2023.10.09 v5.12.0

1. new `isEqual` function, see: [isEqual](https://github.com/saqqdy/js-cool#isequal)
Expand Down
14 changes: 13 additions & 1 deletion README-zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,19 @@ const functionList = {
mountStyle, // 动态加载css样式
preloader, // 图片预加载
waiting, // 等待一段时间
awaitTo // 替代try catch处理promise错误
awaitTo, // 替代try catch处理promise错误
// 二进制
arrayBufferToBase64, // arrayBuffer转Base64
arrayBufferToBlob, // arrayBuffer转Blob
base64ToArrayBuffer, // base64转ArrayBuffer
base64ToBlob, // base64转Blob
base64ToFile, // base64转File
blobToArrayBuffer, // blob转ArrayBuffer
blobToBase64, // blob转Base64
blobToUrl, // blob转Url
fileToBase64, // file转Base64
svgToBlob, // svg转Blob
urlToBlob // url转Blob
}
```

Expand Down
311 changes: 311 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,18 @@ Collection of common JavaScript / TypeScript utilities
- [preloader](#preloader)
- [waiting](#waiting)
- [awaitTo](#awaitto)
- [Blob arrayBuffer base64 file blobUrl](#blob-arraybuffer-base64-file-bloburl)
- [arrayBufferToBase64](#arraybuffertobase64)
- [arrayBufferToBlob](#arraybuffertoblob)
- [base64ToArrayBuffer](#base64toarraybuffer)
- [base64ToBlob](#base64toblob)
- [base64ToFile](#base64tofile)
- [blobToArrayBuffer](#blobtoarraybuffer)
- [blobToBase64](#blobtobase64)
- [blobToUrl](#blobtourl)
- [fileToBase64](#filetobase64)
- [svgToBlob](#svgtoblob)
- [urlToBlob](#urltoblob)
- [Support & Issues](#support--issues)
- [License](#license)

Expand Down Expand Up @@ -3572,6 +3584,305 @@ const [err, data] = await to([promise1, promise2])
declare function awaitTo<T, E = Error>(promise: Promise<T>): Promise<[E, undefined] | [null, T]>
```

### Blob arrayBuffer base64 file blobUrl

#### arrayBufferToBase64

arrayBuffer转Base64

- Since: `5.13.0`

- Arguments:

| Parameters | Description | Type | Optional | Required | Default |
| ---------- | ----------- | -------- | -------- | -------- | ------- |
| source | source data | `String` | - | `false` | - |

- Returns: `Object`

- Example:

```ts
arrayBufferToBase64()
// result
```

- Types:

```ts
declare function arrayBufferToBase64<T>(source: T): any
```

#### arrayBufferToBlob

arrayBuffer转Blob

- Since: `5.13.0`

- Arguments:

| Parameters | Description | Type | Optional | Required | Default |
| ---------- | ----------- | -------- | -------- | -------- | ------- |
| source | source data | `String` | - | `false` | - |

- Returns: `Object`

- Example:

```ts
arrayBufferToBlob()
// result
```

- Types:

```ts
declare function arrayBufferToBlob<T>(source: T): any
```

#### base64ToArrayBuffer

base64转ArrayBuffer

- Since: `5.13.0`

- Arguments:

| Parameters | Description | Type | Optional | Required | Default |
| ---------- | ----------- | -------- | -------- | -------- | ------- |
| source | source data | `String` | - | `false` | - |

- Returns: `Object`

- Example:

```ts
base64ToArrayBuffer()
// result
```

- Types:

```ts
declare function base64ToArrayBuffer<T>(source: T): any
```

#### base64ToBlob

base64转Blob

- Since: `5.13.0`

- Arguments:

| Parameters | Description | Type | Optional | Required | Default |
| ---------- | ----------- | -------- | -------- | -------- | ------- |
| source | source data | `String` | - | `false` | - |

- Returns: `Object`

- Example:

```ts
base64ToBlob()
// result
```

- Types:

```ts
declare function base64ToBlob<T>(source: T): any
```

#### base64ToFile

base64转File

- Since: `5.13.0`

- Arguments:

| Parameters | Description | Type | Optional | Required | Default |
| ---------- | ----------- | -------- | -------- | -------- | ------- |
| source | source data | `String` | - | `false` | - |

- Returns: `Object`

- Example:

```ts
base64ToFile()
// result
```

- Types:

```ts
declare function base64ToFile<T>(source: T): any
```

#### blobToArrayBuffer

blob转ArrayBuffer

- Since: `5.13.0`

- Arguments:

| Parameters | Description | Type | Optional | Required | Default |
| ---------- | ----------- | -------- | -------- | -------- | ------- |
| source | source data | `String` | - | `false` | - |

- Returns: `Object`

- Example:

```ts
blobToArrayBuffer()
// result
```

- Types:

```ts
declare function blobToArrayBuffer<T>(source: T): any
```

#### blobToBase64

blob转Base64

- Since: `5.13.0`

- Arguments:

| Parameters | Description | Type | Optional | Required | Default |
| ---------- | ----------- | -------- | -------- | -------- | ------- |
| source | source data | `String` | - | `false` | - |

- Returns: `Object`

- Example:

```ts
blobToBase64()
// result
```

- Types:

```ts
declare function blobToBase64<T>(source: T): any
```

#### blobToUrl

blob转Url

- Since: `5.13.0`

- Arguments:

| Parameters | Description | Type | Optional | Required | Default |
| ---------- | ----------- | -------- | -------- | -------- | ------- |
| source | source data | `String` | - | `false` | - |

- Returns: `Object`

- Example:

```ts
blobToUrl()
// result
```

- Types:

```ts
declare function blobToUrl<T>(source: T): any
```

#### fileToBase64

file转Base64

- Since: `5.13.0`

- Arguments:

| Parameters | Description | Type | Optional | Required | Default |
| ---------- | ----------- | -------- | -------- | -------- | ------- |
| source | source data | `String` | - | `false` | - |

- Returns: `Object`

- Example:

```ts
fileToBase64()
// result
```

- Types:

```ts
declare function fileToBase64<T>(source: T): any
```

#### svgToBlob

svg转Blob

- Since: `5.13.0`

- Arguments:

| Parameters | Description | Type | Optional | Required | Default |
| ---------- | ----------- | -------- | -------- | -------- | ------- |
| source | source data | `String` | - | `false` | - |

- Returns: `Object`

- Example:

```ts
svgToBlob()
// result
```

- Types:

```ts
declare function svgToBlob<T>(source: T): any
```

#### urlToBlob

url转Blob

- Since: `5.13.0`

- Arguments:

| Parameters | Description | Type | Optional | Required | Default |
| ---------- | ----------- | -------- | -------- | -------- | ------- |
| source | source data | `String` | - | `false` | - |

- Returns: `Object`

- Example:

```ts
urlToBlob()
// result
```

- Types:

```ts
declare function urlToBlob<T>(source: T): any
```

## Support & Issues

Please open an issue [here](https://github.com/saqqdy/js-cool/issues).
Expand Down
11 changes: 11 additions & 0 deletions src/arrayBufferToBase64.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* String, number to base64
*
* @param input - the string to be encoded
* @returns - the BASE64 encoding
*/
function arrayBufferToBase64(input: string) {
//
}

export default arrayBufferToBase64
11 changes: 11 additions & 0 deletions src/arrayBufferToBlob.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* String, number to base64
*
* @param input - the string to be encoded
* @returns - the BASE64 encoding
*/
function arrayBufferToBlob(input: string) {
//
}

export default arrayBufferToBlob
Loading

0 comments on commit 56de101

Please sign in to comment.