Skip to content

Commit

Permalink
lib/svgo: rename 'startBytes' to 'inBytes' and 'endBytes' to 'outBytes (
Browse files Browse the repository at this point in the history
close #53)
  • Loading branch information
deepsweet committed Nov 23, 2012
1 parent 2cbb54e commit d35cec2
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
8 changes: 4 additions & 4 deletions examples/fromFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ svgo
// optimize SVG file
.fromFile('examples/test.svg')
// get optimized result
.then(function(min) {
.then(function(result) {

console.log(min);
console.log(result);
// output:
// {
// // optimized SVG data string
Expand All @@ -16,8 +16,8 @@ svgo
// info: {
// width: '10',
// height: '20',
// startBytes: 59,
// endBytes: 38
// inBytes: 59,
// outBytes: 38
// }
// }

Expand Down
8 changes: 4 additions & 4 deletions examples/fromStream.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ svgo
// optimize stream
.fromStream(fileStream)
// get optimized result
.then(function(min) {
.then(function(result) {

console.log(min);
console.log(result);
// output:
// {
// // optimized SVG data string
Expand All @@ -21,8 +21,8 @@ svgo
// info: {
// width: '10',
// height: '20',
// startBytes: 59,
// endBytes: 38
// inBytes: 59,
// outBytes: 38
// }
// }

Expand Down
8 changes: 4 additions & 4 deletions examples/fromString.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ svgo
// optimize SVG data string
.fromString('<svg version="1.1" width="10" height="20">test</svg>')
// get optimized result
.then(function(min) {
.then(function(result) {

console.log(min);
console.log(result);
// output:
// {
// // optimized SVG data string
Expand All @@ -16,8 +16,8 @@ svgo
// info: {
// width: '10',
// height: '20',
// startBytes: 52,
// endBytes: 38
// inBytes: 52,
// outBytes: 38
// }
// }

Expand Down
8 changes: 4 additions & 4 deletions lib/svgo.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ module.exports = INHERIT(/** @lends SVGO.prototype */{
return SVG2JS(str, config.svg2js)
.then(function(jsdata) {

var out = JS2SVG(PLUGINS(jsdata, config.plugins), config.js2svg);
var result = JS2SVG(PLUGINS(jsdata, config.plugins), config.js2svg);

out.info.startBytes = Buffer.byteLength(str, 'utf-8');
out.info.endBytes = Buffer.byteLength(out.data, 'utf-8');
result.info.inBytes = Buffer.byteLength(str, 'utf-8');
result.info.outBytes = Buffer.byteLength(result.data, 'utf-8');

return out;
return result;

});

Expand Down
16 changes: 8 additions & 8 deletions lib/svgo/coa.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,17 @@ module.exports = require('coa').Cmd()
svgo = new SVGO({ coa: opts }).fromFile(input);
}

return svgo.then(function(svgmin) {
return svgo.then(function(result) {

// --datauri
if (opts.datauri) {
// convert to Data URI base64 string
svgmin.data = encodeSVGDatauri(svgmin.data);
result.data = encodeSVGDatauri(result.data);
}

// stdout
if (output === '-' || (input === '-' && !output)) {
process.stdout.write(svgmin.data + '\n');
process.stdout.write(result.data + '\n');
}

// file
Expand All @@ -152,14 +152,14 @@ module.exports = require('coa').Cmd()

// output file
output = FS.createWriteStream(output, { encoding: 'utf8' });
output.write(svgmin.data);
output.write(result.data);
output.end();

// print time info
printTimeInfo(startTime, Date.now());

// print optimization profit info
printProfitInfo(svgmin.info.startBytes, svgmin.info.endBytes);
printProfitInfo(result.info.inBytes, result.info.outBytes);

}

Expand Down Expand Up @@ -230,14 +230,14 @@ function optimizeFolder(folder, opts) {

// then optimize it and output profit information
return svgo.fromFile(item)
.then(function(svgmin) {
.then(function(result) {

var output = FS.createWriteStream(item, { encoding: 'utf8' });
output.write(svgmin.data);
output.write(result.data);
output.end();

UTIL.puts(filename + ':');
printProfitInfo(svgmin.info.startBytes, svgmin.info.endBytes);
printProfitInfo(result.info.inBytes, result.info.outBytes);

});

Expand Down

0 comments on commit d35cec2

Please sign in to comment.