https://github.com/atayahmet/blobify
A Javascript automation tool to convert data (file, image etc.) to blob object and vice-versa.
https://github.com/atayahmet/blobify
blob blob-files blob-image chunking data-chunk inmemory-cache
Last synced: 3 months ago
JSON representation
A Javascript automation tool to convert data (file, image etc.) to blob object and vice-versa.
- Host: GitHub
- URL: https://github.com/atayahmet/blobify
- Owner: atayahmet
- License: mit
- Created: 2019-03-08T12:36:39.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-03-25T13:45:18.000Z (over 6 years ago)
- Last Synced: 2025-03-17T20:11:24.662Z (3 months ago)
- Topics: blob, blob-files, blob-image, chunking, data-chunk, inmemory-cache
- Language: TypeScript
- Homepage:
- Size: 103 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Blobify
A Javascript automation tool to convert from html file object to blob object and more capabilities with creating custom helper function.[](https://badge.fury.io/js/%40atayahmet%2Fblobify)
[](https://travis-ci.org/atayahmet/blobify.svg?branch=master)
[](https://david-dm.org/atayahmet/storage-based-queue)
[](https://snyk.io/test/github/atayahmet/blobify?targetFile=package.json)
[](https://github.com/atayahmet/blobify/blob/master/LICENSE)
[](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<string> | HTML5 File object. |
| base64Decode | string | any | Base64 encoded data. |
| toStream | Blob | Promise<string> | 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