fitool
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

🔧 fitool

TypeScript file functions library.

workflow npm npm NPM

Quickstart:

npm install fitool
# or:
yarn add fitool

Table of contents

  1. Examples
  2. Usage

Examples

Convert text/plain data URL to string

import { download } from 'fitool';

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

Download data URL

import { download } from 'fitool';

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

Usage

toFile(file: File | Blob | string | ArrayBuffer, name?: string): Promise<File>

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

toBlob(file: File | Blob | string | ArrayBuffer): Promise<Blob>

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

toDataURL(file: File | Blob | string | ArrayBuffer): Promise<string>

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

toBlobURL(file: File | Blob | string | ArrayBuffer): Promise<string>

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

toArrayBuffer(file: File | Blob | string | ArrayBuffer): Promise<ArrayBuffer>

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

toString(file: File | Blob | string | ArrayBuffer): Promise<string>

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<void>

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

Package Sidebar

Install

npm i fitool

Weekly Downloads

13

Version

1.0.4

License

BSD-3-Clause-Clear

Unpacked Size

26.8 kB

Total Files

18

Last publish

Collaborators

  • mat-sz