You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP

base64-async

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

base64-async

Non-blocking chunked base64 encoding

2.0.0
Version published
Weekly downloads
1.2K
-43.3%
Maintainers
1
Weekly downloads
 
Created

base64-async

Non-blocking chunked base64 encoding

Build Status Coverage Status npm

Install

npm install --save base64-async

Usage

const b64 = require('base64-async');
const fs = require('fs');
const fileBuffer = fs.readFileSync('somehugefile.jpg');

console.log(fileBuffer);
// <Buffer 68 69 20 6d 75 6d ... >

b64.encode(fileBuffer)
  .then(b64String => {
      console.log(b64String);
      // aGkgbXVt...

      return b64.decode(b64String);
  })
  .then(originalFileBuffer => {
    console.log(originalFileBuffer);
    // <Buffer 68 69 20 6d 75 6d ... >
  });

// or, for the cool kids

const b64String = await b64.encode(fileBuffer);
const originalFileBuffer = await b64.decode(b64String);

// which is equivalent to this

const b64String = await b64(fileBuffer);
const originalFileBuffer = await b64(b64String);

// Buffers are encoded, strings are decoded

License

MIT © Luke Childs

FAQs

Package last updated on 23 May 2017

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