Socket
Book a DemoInstallSign in
Socket

@atayahmet/blobify

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@atayahmet/blobify

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

1.1.4
latest
Source
npmnpm
Version published
Weekly downloads
4
Maintainers
1
Weekly downloads
 
Created
Source

Blobify

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

npm version Build Status Dependency Status Known Vulnerabilities GitHub license GitHub issues

Getting Started

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

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

Installing

npm i @atayahmet/blobify --save

or

yarn add @atayahmet/blobify

Running the tests

npm test

Built-in Helpers

NameParameter TypeReturnDescription
pipeFunctionBlobify class instancePipe itarator.
createBlobstring[]BlobCreate blob object from chunks.
chunkIChunkOptionsUint8Array[]Chunk generator.
base64EncodeFilePromise<string>HTML5 File object.
base64DecodestringanyBase64 encoded data.
toStreamBlobPromise<string>Convert blob object to readable content.

IChunkOptions

NameTypeDescription
chunksstring or Uint8ArrayData format.
slicenumber (optional)Per chunk size. (Default 512)
typestringFile content type.

Quick Example

Convert the file to uploadable form.

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:

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

Built With

  • TypeScript

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

See also the list of contributors who participated in this project.

License

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

Keywords

blob

FAQs

Package last updated on 25 Mar 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.