JSPM

  • Created
  • Published
  • Downloads 242340
  • Score
    100M100P100Q208539F
  • License MIT

A simple Data URI scheme generator

Package Exports

  • datauri

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 (datauri) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

datauri Build Status

A simple Data URI scheme generator built on top of Node.js. To install datauri, just run:

npm install -g datauri (it may require Root privileges)

CLIENT

To print a datauri scheme from a file

$ datauri brand.png

CSS Background

You can generate or update an output css file with datauri background:

$ datauri brand.png asset/background.css

If you want to define a Class Name, just type:

$ datauri brand.png asset/background.css MyNewClass

API

var Datauri = require('datauri');

// without instance
var datauri = Datauri('test/myfile.png');
console.log(datauri); //=> "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...";

// with instance
var dUri = new Datauri('test/myfile.png');

console.log(dUri.content); //=> "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...";
console.log(dUri.mimetype); //=> "image/png";
console.log(dUri.base64); //=> "iVBORw0KGgoAAAANSUhEUgAA...";
console.log(dUri.getCSS()); //=> "\n.case {\n    background: url('data:image/png;base64,iVBORw...";
console.log(dUri.getCSS("myClass")); //=> "\n.myClass {\n    background: url('data:image/png;base64,iVBORw...";

DEVELOPING

The only essential library to develop datauri is jshint.

$ make install
$ make test

If you'd like to test the full process including npm installer, just run:

$ make fulltest

License

MIT License (c) Helder Santana