# @atayahmet/blobify

> A Javascript automation tool to convert file to blob object and vice-versa.

Latest version **1.1.4** (published 2019-03-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install @atayahmet/blobify
pnpm add @atayahmet/blobify
yarn add @atayahmet/blobify
bun add @atayahmet/blobify
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.4 |
| Published | 2019-03-25 |
| First published | 2019-03-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 16.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Ahmet ATAY |
| Maintainers | atayahmet |
| Keywords | blob, chunks, file, images |

## Links

- npm: https://www.npmjs.com/package/@atayahmet/blobify
- Repository: https://github.com/atayahmet/blobify
- Homepage: https://github.com/atayahmet/blobify#readme
- Issues: https://github.com/atayahmet/blobify/issues
- npm.io page: https://npm.io/package/@atayahmet/blobify

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 1.1.4 (latest) — 2019-03-25
- 1.1.2 — 2019-03-23
- 1.1.1 — 2019-03-23
- 1.0.0 — 2019-03-08

## README

# Blobify
A Javascript automation tool to convert from html file object to blob object and more capabilities with creating custom helper function.

[![npm version](https://badge.fury.io/js/%40atayahmet%2Fblobify.svg)](https://badge.fury.io/js/%40atayahmet%2Fblobify)
[![Build Status](https://travis-ci.org/atayahmet/blobify.svg?branch=master)](https://travis-ci.org/atayahmet/blobify.svg?branch=master)
[![Dependency Status](https://img.shields.io/david/atayahmet/storage-based-queue.svg?style=flat-square)](https://david-dm.org/atayahmet/storage-based-queue)
[![Known Vulnerabilities](https://snyk.io/test/github/atayahmet/blobify/badge.svg?targetFile=package.json)](https://snyk.io/test/github/atayahmet/blobify?targetFile=package.json)
[![GitHub license](https://img.shields.io/github/license/atayahmet/storage-based-queue.svg)](https://github.com/atayahmet/blobify/blob/master/LICENSE)
[![GitHub issues](https://img.shields.io/github/issues/atayahmet/storage-based-queue.svg)](https://github.com/atayahmet/blobify/issues)

## Getting Started

```ts
import { chunk } from '@atayahmet/blobify';

chunk({ chars: stream, slice: 128, type: 'image/jpg' })
```

### Installing

```sh
npm i @atayahmet/blobify --save
```
or

```sh
yarn add @atayahmet/blobify
```

## Running the tests

```ts
npm test
```

### Built-in Helpers

| Name         | Parameter Type | Return                 | Description                             |
|--------------|----------------|------------------------|-----------------------------------------|
| pipe         | Function       | Blobify class instance | Pipe itarator.                          |
| createBlob   | string[]       | Blob                   | Create blob object from chunks.         |
| chunk        | IChunkOptions  | Uint8Array[]           | Chunk generator.                        |
| base64Encode | File           | Promise&lt;string&gt;  | HTML5 File object.                      |
| base64Decode | string         | any                    | Base64 encoded data.                    |
| toStream     | Blob           | Promise&lt;string&gt;  | Convert blob object to readable content.|

### IChunkOptions

| Name   | Type                 | Description                   |
|--------|----------------------|-------------------------------|
| chunks | string or Uint8Array | Data format.                  |
| slice  | number (optional)    | Per chunk size. (Default 512) |
| type   | string               | File content type.            |

## Quick Example

Convert the file to uploadable form.

```ts
import { pipe, chunk, createBlob, base64Encode } from '@atayahmet/blobify';

const file = document.getElementById('image');

pipe(() => base64Encode(file))
  .pipe(stream => chunk({ chars: stream, slice: 128 }))
  .pipe(chunks => createBlob(chunks, "image/jpeg"))
  .catch(console.error)
  .run()
  .then(resul => {
    console.log(result);
  });
```

Vice versa:

```ts
pipe(() => toStream(blob))
  .pipe(stream => base64Decode(stream))
  .pipe(data => {
      // do some maniplation...
      return data;
  })
  .run()
  .then(result => {
    // ...
  });
```

## Built With

* [TypeScript](https://www.typescriptlang.org) 

## Versioning

We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/your/project/tags). 

## Authors

* [**Ahmet ATAY**](https://github.com/atayahmet) - *Initial work*

See also the list of [contributors](https://github.com/your/project/contributors) who participated in this project.

## License

This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details

---
_Source: https://npm.io/package/@atayahmet/blobify · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
