Pathologic was missing because of a .git folder inside.
[yaffs-website] / node_modules / gzip-size / index.js
1 'use strict';
2 var duplexer = require('duplexer');
3 var stream = require('stream');
4 var zlib = require('zlib');
5 var opts = {level: 9};
6
7 module.exports = function (str, cb) {
8         if (!str) {
9                 cb(null, 0);
10                 return;
11         }
12
13         zlib.gzip(str, opts, function (err, data) {
14                 if (err) {
15                         cb(err, 0);
16                         return;
17                 }
18
19                 cb(err, data.length);
20         });
21 };
22
23 module.exports.sync = function (str) {
24         return zlib.gzipSync(str, opts).length;
25 };
26
27 module.exports.stream = function () {
28         var input = new stream.PassThrough();
29         var output = new stream.PassThrough();
30         var wrapper = duplexer(input, output);
31
32         var gzipSize = 0;
33         var gzip = zlib.createGzip(opts)
34                 .on('data', function (buf) {
35                         gzipSize += buf.length;
36                 })
37                 .on('error', function () {
38                         wrapper.gzipSize = 0;
39                 })
40                 .on('end', function () {
41                         wrapper.gzipSize = gzipSize;
42                         wrapper.emit('gzip-size', gzipSize);
43                         output.end();
44                 });
45
46         input.pipe(gzip);
47         input.pipe(output, {end: false});
48
49         return wrapper;
50 };