dataurify

1.0.4 • Public • Published

dataurify

js-standard-style Build Status

Turn a buffer into a data URI

Usage

'use strict'

var hyperquest = require('hyperquest')
var dataurify = require('./index')

var buffer = []

var req = hyperquest.get('http://video.webmfiles.org/big-buck-bunny_trailer.webm')
req.on('response', function (res) {
  res.on('data', function (chunk) {
    buffer.push(chunk)
  })
  res.on('end', function () {
    console.log(dataurify(Buffer.concat(buffer))) // data:video/webm;base64,...
  })
})

Install

$ npm install dataurify

Supported types

https://github.com/sindresorhus/file-type#supported-file-types

API

dataurify(buffer)

Pass in a single buffer and get back a functional data URI. Check supported types to see if your content is supported.

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i dataurify

Weekly Downloads

2

Version

1.0.4

License

MIT

Last publish

Collaborators

  • nlocnila