datauri-stream
Lightweight data
─► data URI
transform stream.
examples
Use with the file system:
var DataUri = require('datauri-stream')
var fs = require('fs')
fs.createReadStream('./picture.jpg')
.pipe(DataUri())
.pipe(process.stdout)
Use with http requests:
var DataUri = require('datauri-stream')
var http = require('http')
http.get('http://josephdykstra.com/logo.png', function(res) {
res.pipe(DataUri())
.pipe(process.stdout)
})
Use on the browser with browserify:
var DataUri = require('datauri-stream')
var hyperquest = require('hyperquest')
var concat = require('concat-stream')
hyperquest('https://www.npmjs.com/static/images/npm-logo.svg')
.pipe(DataUri({ mime: 'image/svg' }))
.pipe(concat(function (dataUri) {
var img = document.createElement('img')
img.src = dataUri
document.body.appendChild(img)
}))
api
var DataUriStream = require('datauri-stream')
var ts = DataUriStream([opts])
opts.mime
An optional override for the mime type.
The mime type will be automatically detected otherwise, using the file-type module. It supports many file types.
If the source is not a file, then you'll want to supply the mime type.
ts
A standard Transform Stream. Pipe to and from it.
install
With npm do:
npm install datauri-stream
see also
license
VOL