JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 665707
  • Score
    100M100P100Q176350F
  • License MIT

Contains new Node.js v0.10 style stream classes for encoding / decoding Base64 data

Package Exports

  • base64-stream

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (base64-stream) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Introduction

While Node.js has built-in support for Base64 data, it does not come with the ability to encode / decode data in a stream.

This library contains a streaming Base64 encoder and a streaming Base64 decoder for use with Node.js. These classes are written using the new Node.js v0.10 stream interfaces and are well covered with unit tests.

Usage

Installation

To install base64-stream

npm install base64-stream

Examples

This example encodes an image and pipes it to stdout.

var http = require('http');
var base64 = require('base64-stream');

var img = 'http://farm3.staticflickr.com/2433/3973241798_86ddfa642b_o.jpg';
http.get(img, function(res) {
    if (res.statusCode === 200)
        res.pipe(base64.encode()).pipe(process.stdout);
});

This example takes in Base64 encoded data on stdin, decodes it, an pipes it to stdout.

var base64 = require('base64-stream');
process.stdin.pipe(base64.decode()).pipe(process.stdout);

You may also treat encode / decode as classes, so the following is also valid:

var Base64Decode = require('base64-stream').decode;
var stream = new Base64Decode();
...

Requirements

This module currently requires Node v0.8 or higher. Support for versions prior to v0.10 is made possible by using the readable-stream module.

Testing

To run the unit tests

npm test

License

MIT