Socket
Socket
Sign inDemoInstall

svgo

Package Overview
Dependencies
17
Maintainers
1
Versions
103
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.8 to 0.1.9

plugins/cleanupIDs.js

10

CHANGELOG.md

@@ -0,1 +1,11 @@

### [ [>](https://github.com/svg/svgo/tree/v0.1.9) ] 0.1.9 / 17.12.2012
* plugins/cleanupIDs: renamed from removeUnusedIDs; minify used IDs (fix [#7](https://github.com/svg/svgo/issues/7))
* lib/svgo/js2svg: restore HTML entities back (fix [#80](https://github.com/svg/svgo/issues/80) + [#81](https://github.com/svg/svgo/issues/81))
* plugins/removeDoctype: do not remove if custom XML entities presents (fix [#77](https://github.com/svg/svgo/issues/77))
* lib/svgo/coa: refactoring, colors and fix [#70](https://github.com/svg/svgo/issues/70)
* lib/svgo: store elapsed time in result object
* usage examples with SVGZ (close [#18](https://github.com/svg/svgo/issues/18))
* more optimized logo
* update `.gitignore`
### [ [>](https://github.com/svg/svgo/tree/v0.1.8) ] 0.1.8 / 11.12.2012

@@ -2,0 +12,0 @@ * new plugin [plugins/removeUselessStrokeAndFill](https://github.com/svg/svgo/blob/master/plugins/removeUselessStrokeAndFill.js) (close [#75](https://github.com/svg/svgo/issues/75))

28

examples/fromFile.js

@@ -13,17 +13,21 @@ 'use strict';

console.log(result);
// output:
// {
// // optimized SVG data string
// data: '<svg width="10" height="20">test</svg>'
// // additional info such as width/height and start/end bytes length
// info: {
// width: '10',
// height: '20',
// inBytes: 59,
// outBytes: 38
// }
// }
/*
output:
{
// optimized SVG data string
data: '<svg width="10" height="20">test</svg>'
// additional info such as width/height and start/end bytes length
info: {
width: '10',
height: '20',
inBytes: 59,
outBytes: 38,
time: N
}
}
*/
})
// end promises chain
.done();

@@ -18,17 +18,21 @@ 'use strict';

console.log(result);
// output:
// {
// // optimized SVG data string
// data: '<svg width="10" height="20">test</svg>'
// // additional info such as width/height and start/end bytes length
// info: {
// width: '10',
// height: '20',
// inBytes: 59,
// outBytes: 38
// }
// }
/*
output:
{
// optimized SVG data string
data: '<svg width="10" height="20">test</svg>'
// additional info such as width/height and start/end bytes length
info: {
width: '10',
height: '20',
inBytes: 59,
outBytes: 38,
time: N
}
}
*/
})
// end promises chain
.done();

@@ -13,17 +13,21 @@ 'use strict';

console.log(result);
// output:
// {
// // optimized SVG data string
// data: '<svg width="10" height="20">test</svg>'
// // additional info such as width/height and start/end bytes length
// info: {
// width: '10',
// height: '20',
// inBytes: 52,
// outBytes: 38
// }
// }
/*
output:
{
// optimized SVG data string
data: '<svg width="10" height="20">test</svg>'
// additional info such as width/height and start/end bytes length
info: {
width: '10',
height: '20',
inBytes: 52,
outBytes: 38,
time: N
}
}
*/
})
// end promises chain
.done();

@@ -51,2 +51,4 @@ 'use strict';

var startTime = Date.now();
str = decodeSVGDatauri(str);

@@ -65,2 +67,4 @@

result.info.time = Date.now() - startTime;
return result;

@@ -67,0 +71,0 @@

'use strict';
require('colors');
var FS = require('fs'),

@@ -102,3 +104,2 @@ QFS = require('q-fs'),

folder = opts.folder,
startTime = Date.now(),
svgo;

@@ -137,56 +138,69 @@

if (result.info.outBytes >= result.info.inBytes) {
// --datauri
if (opts.datauri) {
// convert to Data URI base64 string
result.data = encodeSVGDatauri(result.data);
}
UTIL.puts('\nThere is nothing to optimize!\n');
// stdout
if (output === '-' || (input === '-' && !output)) {
process.stdout.write(result.data + '\n');
}
} else {
// file
else {
// --datauri
if (opts.datauri) {
// convert to Data URI base64 string
result.data = encodeSVGDatauri(result.data);
// if input is from file - overwrite it
if (!output && input) {
output = input;
}
// stdout
if (output === '-' || (input === '-' && !output)) {
process.stdout.write(result.data + '\n');
}
UTIL.puts('\r');
saveFileAndPrintInfo(result, output, opts.pretty);
// file
else {
}
// if input is from file - overwrite it
if (!output && input) {
output = input;
}
})
.done();
// output file
output = FS.createWriteStream(output, { encoding: 'utf8' });
output.write(result.data);
output.end();
});
// print time info
printTimeInfo(startTime, Date.now());
/**
* Save file and print info.
*
* @param {Object} result SVGO result
* @param {String} output output filename
* @param {Boolean} pretty is pretty printed?
*/
function saveFileAndPrintInfo(result, output, pretty) {
// print optimization profit info
printProfitInfo(result.info.inBytes, result.info.outBytes);
if (!pretty && result.info.outBytes >= result.info.inBytes) {
}
UTIL.puts('There is nothing to optimize!\n'.yellow);
}
} else {
})
.done();
// output file
output = FS.createWriteStream(output, { encoding: 'utf8' });
output.write(result.data);
output.end();
});
// print time info
printTimeInfo(result.info.time);
// print optimization profit info
printProfitInfo(result.info.inBytes, result.info.outBytes);
}
}
/**
* Print time info.
*
* @param {Date} startTime start time
* @param {Date} endTime end time
* @param {Number} time working time in ms
*/
function printTimeInfo(startTime, endTime) {
function printTimeInfo(time) {
UTIL.puts('\nDone in ' + (endTime - startTime) + ' ms!\n');
UTIL.puts('Done in ' + time + ' ms!');

@@ -206,4 +220,5 @@ }

UTIL.puts(
(Math.round((inBytes / 1024) * 1000) / 1000) + ' KiB - ' +
(Math.round(profitPercents * 10) / 10) + '% = ' +
(Math.round((inBytes / 1024) * 1000) / 1000) + ' KiB' +
(profitPercents < 0 ? ' + ' : ' - ') +
String(Math.abs((Math.round(profitPercents * 10) / 10)) + '%').green + ' = ' +
(Math.round((outBytes / 1024) * 1000) / 1000) + ' KiB\n'

@@ -248,8 +263,4 @@ );

var output = FS.createWriteStream(item, { encoding: 'utf8' });
output.write(result.data);
output.end();
UTIL.puts(filename + ':');
printProfitInfo(result.info.inBytes, result.info.outBytes);
saveFileAndPrintInfo(result, item, opts.pretty);

@@ -261,3 +272,5 @@ });

})
.done();
.fail(function(e) {
UTIL.puts(filename + ':\n' + String('Error! "' + e.message + '"').red + '\n');
});

@@ -264,0 +277,0 @@ });

@@ -270,2 +270,7 @@ 'use strict';

// convert entities back
for (var entity in this.config.entities) {
text = text.split(entity).join(this.config.entities[entity]);
}
return this.createIndent() +

@@ -272,0 +277,0 @@ this.config.textStart +

{
"name": "svgo",
"version": "0.1.8",
"version": "0.1.9",
"description": "Nodejs-based tool for optimizing SVG vector graphics files",

@@ -46,3 +46,4 @@ "keywords": [ "svgo", "svg", "optimize", "minify" ],

"node.extend": "",
"yamljs": "~0.1.3"
"yamljs": "~0.1.3",
"colors": "~0.6.0"
},

@@ -49,0 +50,0 @@ "devDependencies": {

@@ -17,2 +17,8 @@ 'use strict';

*
* @example
* <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
* "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" [
* <!-- an internal subset can be embedded here -->
* ]>
*
* @param {Object} item current iteration item

@@ -25,4 +31,8 @@ * @return {Boolean} if false, item will be filtered out

return !item.doctype;
// remove doctype only if custom XML entities declaration block does not presents
// http://en.wikipedia.org/wiki/Document_Type_Definition#Entity_declarations
if (item.doctype && item.doctype.substr(-1) !== ']') {
return false;
}
};

@@ -6,3 +6,3 @@ **english** | [русский](https://github.com/svg/svgo/blob/master/README.ru.md)

## SVGO v0.1.8 [![Build Status](https://secure.travis-ci.org/svg/svgo.png)](http://travis-ci.org/svg/svgo)
## SVGO v0.1.9 [![Build Status](https://secure.travis-ci.org/svg/svgo.png)](http://travis-ci.org/svg/svgo)

@@ -40,2 +40,3 @@ **SVG O**ptimizer is a Nodejs-based tool for optimizing SVG vector graphics files.

* [ [>](https://github.com/svg/svgo/blob/master/plugins/removeUnusedNS.js) ] remove unused namespaces declaration
* [ [>](https://github.com/svg/svgo/blob/master/plugins/cleanupIDs.js) ] remove unused and minify used IDs
* [ [>](https://github.com/svg/svgo/blob/master/plugins/cleanupNumericValues.js) ] round numeric values to the fixed precision, remove default 'px' units

@@ -100,2 +101,12 @@ * [ [>](https://github.com/svg/svgo/blob/master/plugins/moveElemsAttrsToGroup.js) ] move elements attributes to the existing group wrapper

* with SVGZ:
from `.svgz` to `.svg`:
$ gunzip -c test.svgz | svgo -i - -o test.min.svg
from `.svg` to `.svgz`:
$ svgo test.svg -o - | gzip -cfq9 > test.svgz
* with GUI – [svgo-gui](https://github.com/svg/svgo-gui)

@@ -108,3 +119,2 @@ * as a Nodejs module – [examples](https://github.com/svg/svgo/tree/master/examples)

* [v0.1.x](https://github.com/svg/svgo/issues?milestone=6&state=open)
* [v0.2.x](https://github.com/svg/svgo/issues?milestone=7&state=open)

@@ -111,0 +121,0 @@

@@ -6,3 +6,3 @@ [english](https://github.com/svg/svgo/blob/master/README.md) | **русский**

## SVGO v0.1.8 [![Build Status](https://secure.travis-ci.org/svg/svgo.png)](http://travis-ci.org/svg/svgo)
## SVGO v0.1.9 [![Build Status](https://secure.travis-ci.org/svg/svgo.png)](http://travis-ci.org/svg/svgo)

@@ -40,2 +40,3 @@ **SVG** **O**ptimizer – это инструмент для оптимизации векторной графики в формате SVG, написанный на Node.js.

* [ [>](https://github.com/svg/svgo/blob/master/plugins/removeUnusedNS.js) ] удаление деклараций неиспользуемых пространств имён
* [ [>](https://github.com/svg/svgo/blob/master/plugins/cleanupIDs.js) ] удаление неиспользуемых и сокращение используемых ID
* [ [>](https://github.com/svg/svgo/blob/master/plugins/cleanupNumericValues.js) ] округление дробных чисел до заданной точности, удаление `px` как единицы измерения по умолчанию

@@ -100,2 +101,12 @@ * [ [>](https://github.com/svg/svgo/blob/master/plugins/moveElemsAttrsToGroup.js) ] перемещение совпадающих атрибутов у всех элементов внутри группы `<g>`

* с SVGZ:
из `.svgz` в `.svg`:
$ gunzip -c test.svgz | svgo -i - -o test.min.svg
из `.svg` в `.svgz`:
$ svgo test.svg -o - | gzip -cfq9 > test.svgz
* с помощью GUI – [svgo-gui](https://github.com/svg/svgo-gui)

@@ -108,3 +119,2 @@ * как модуль Node.js – [examples](https://github.com/svg/svgo/tree/master/examples)

* [v0.1.x](https://github.com/svg/svgo/issues?milestone=6&state=open)
* [v0.2.x](https://github.com/svg/svgo/issues?milestone=7&state=open)

@@ -111,0 +121,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc