/
urify.js
53 lines (39 loc) · 842 Bytes
/
urify.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
* imacss
*
* Copyright(c) 2014 André König <andre.koenig@posteo.de>
* MIT Licensed
*
*/
/**
* @author André König <andre.koenig@posteo.de>
*
*/
'use strict';
var stream = require('stream');
var util = require('util');
var Utilities = require('./utilities');
/**
* The stream which generate the data URI of the image.
*
* @param {object} options Stream options.
*
*/
function Urify (options) {
options = options || {};
options.objectMode = true;
stream.Transform.call(this, options);
}
util.inherits(Urify, stream.Transform);
/**
* The transformation process.
*
*/
Urify.prototype._transform = function _transform (image, enc, cb) {
image.datauri = Utilities.getDataURI(image.mime, image.base64);
this.push(image);
cb();
};
module.exports = function () {
return new Urify();
};