Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mat-sz/fitool

📂 TypeScript file functions library.
https://github.com/mat-sz/fitool

blob data-url filereader filereader-api javascript javascript-library typescript typescript-library

Last synced: 8 days ago
JSON representation

📂 TypeScript file functions library.

Awesome Lists containing this project

README

        

🔧 fitool


TypeScript file functions library.


workflow

npm
npm
NPM


Quickstart:

```sh
npm install fitool
# or:
yarn add fitool
```

## Table of contents

1. [Examples](#examples)
2. [Usage](#usage)

## Examples

### Convert `text/plain` data URL to string

```js
import { download } from 'fitool';

async function example() {
const result = await toString('data:text/plain,abc');
// result = abc
}
```

### Download data URL

```js
import { download } from 'fitool';

async function example() {
await download('data:image/png;base64,...');
}
```

## Usage

### toFile(file: File | Blob | string | ArrayBuffer, name?: string): Promise\

Converts a given `File`, `Blob`, `ArrayBuffer`, data URL, blob URL or string to a `File`.

### toBlob(file: File | Blob | string | ArrayBuffer): Promise\

Converts a given `File`, `Blob`, `ArrayBuffer`, data URL, blob URL or string to a `Blob`.

### toDataURL(file: File | Blob | string | ArrayBuffer): Promise\

Converts a given `File`, `Blob`, `ArrayBuffer`, data URL, blob URL or string to a data URL.

### toBlobURL(file: File | Blob | string | ArrayBuffer): Promise\

Converts a given `File`, `Blob`, `ArrayBuffer`, data URL, blob URL or string to a blob URL.

### toArrayBuffer(file: File | Blob | string | ArrayBuffer): Promise\

Converts a given `File`, `Blob`, `ArrayBuffer`, data URL, blob URL or string to an `ArrayBuffer`.

### toString(file: File | Blob | string | ArrayBuffer): Promise\

Converts a given `File`, `Blob`, `ArrayBuffer`, data URL, blob URL or string to an UTF-8 string.

### download(file: File | Blob | string | ArrayBuffer, name: string): Promise\

Initiates a download for a given `File`, `Blob`, `ArrayBuffer`, data URL, blob URL or string.