Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

datauri-stream

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

datauri-stream

Lightweight data -> data URI transform stream

latest
Source
npmnpm
Version
1.0.3
Version published
Maintainers
1
Created
Source

datauri-stream

Build Status

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)
// 'data:image/jpg;base64,iVBORw0KGg...'

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)
	// 'data:image/png;base64,Vs8uZ29vZG...'
})

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

  • pipe-transform-cli - Command line utility to pipe one input encoding to another encoding

license

VOL

Keywords

data uri

FAQs

Package last updated on 28 Sep 2016

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