Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/mat-sz/fitool
- Owner: mat-sz
- License: bsd-3-clause-clear
- Created: 2020-02-28T20:42:53.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-08-23T16:22:57.000Z (over 1 year ago)
- Last Synced: 2024-12-12T00:22:32.456Z (about 1 month ago)
- Topics: blob, data-url, filereader, filereader-api, javascript, javascript-library, typescript, typescript-library
- Language: TypeScript
- Size: 86.9 KB
- Stars: 3
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
🔧 fitool
TypeScript file functions library.
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.