Parser and builder for `data:` URIs
npm install strong-data-uri

data: URIs specified by RFC2397,Call dataUri.decode(uri) to parse the payload of a data URI. The uri
argument expects a string.
``js
var dataUri = require('strong-data-uri');
var uri = 'data:text/plain;charset=iso-8859-1;base64,aGVsbG8gd29ybGQ=';
var buffer = dataUri.decode(uri);
console.log(buffer);
//
console.log(buffer.toString('ascii'));
// Hello world
console.log(buffer.mimetype); // text/plain
console.log(buffer.mediatype); // text/plain;charset=iso-8859-1
console.log(buffer.charset); // iso-8859-1
`
Use dataUri.encode(data, mediatype) to build a new data URI. The dataBuffer
argument can be a or a String. Strings are converted to buffersutf-8
using encoding.
If mediatype is not specified, then application/octet-stream is usedtext/plain;charset=UTF-8
as a default if the data is a Buffer, and if
the data is a String.
`js
var dataUri = require('strong-data-uri');
uri = dataUri.encode('foo');
console.log(uri);
// data:text/plain;charset=UTF-8;base64,Zm9v
uri = dataUri.encode(new Buffer('
console.log(uri);
// data:text/xml;base64,PGZvby8+
``
To keep this project small and light, no command-line tool is provided. If you
need one, please consider data-colon.