Comparing version 2.0.0 to 2.0.1
@@ -26,3 +26,3 @@ 'use strict'; | ||
const optimize = (svgstr, config) => { | ||
const optimize = (input, config) => { | ||
if (config == null) { | ||
@@ -42,3 +42,4 @@ config = {}; | ||
for (let i = 0; i < maxPassCount; i += 1) { | ||
svgjs = svg2js(svgstr); | ||
info.multipassCount = i; | ||
svgjs = svg2js(input); | ||
if (svgjs.error == null) { | ||
@@ -56,4 +57,4 @@ const plugins = config.plugins || defaultPlugins; | ||
} | ||
info.multipassCount = i; | ||
if (svgjs.data.length < prevResultSize) { | ||
input = svgjs.data; | ||
prevResultSize = svgjs.data.length | ||
@@ -60,0 +61,0 @@ } else { |
@@ -11,3 +11,3 @@ /* jshint quotmark: false */ | ||
const { encodeSVGDatauri, decodeSVGDatauri } = require('./tools.js'); | ||
const regSVGFile = /\.svg$/; | ||
const regSVGFile = /\.svg$/i; | ||
const noop = () => {}; | ||
@@ -141,3 +141,3 @@ | ||
if (opts.indent != null) { | ||
config.js2svg.indent = indent; | ||
config.js2svg.indent = opts.indent; | ||
} | ||
@@ -144,0 +144,0 @@ } |
@@ -14,28 +14,27 @@ 'use strict'; | ||
module.exports = function(data, info, plugins) { | ||
const perItemPlugins = []; | ||
const perItemReversePlugins = []; | ||
const fullPlugins = []; | ||
// Try to group sequential elements of plugins array | ||
// to optimize ast traversing | ||
const groups = []; | ||
let prev; | ||
for (const plugin of plugins) { | ||
switch(plugin.type) { | ||
if (prev && plugin.type == prev[0].type) { | ||
prev.push(plugin); | ||
} else { | ||
prev = [plugin]; | ||
groups.push(prev); | ||
} | ||
} | ||
for (const group of groups) { | ||
switch(group[0].type) { | ||
case 'perItem': | ||
perItemPlugins.push(plugin); | ||
data = perItem(data, info, group); | ||
break; | ||
case 'perItemReverse': | ||
perItemReversePlugins.push(plugin); | ||
data = perItem(data, info, group, true); | ||
break; | ||
case 'full': | ||
fullPlugins.push(plugin); | ||
data = full(data, info, group); | ||
break; | ||
} | ||
} | ||
if (perItemPlugins.length !== 0) { | ||
data = perItem(data, info, perItemPlugins); | ||
} | ||
if (perItemReversePlugins.length !== 0) { | ||
data = perItem(data, info, perItemReversePlugins, true); | ||
} | ||
if (fullPlugins.length !== 0) { | ||
data = full(data, info, fullPlugins); | ||
} | ||
return data; | ||
@@ -42,0 +41,0 @@ }; |
{ | ||
"name": "svgo", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Nodejs-based tool for optimizing SVG vector graphics files", | ||
@@ -49,10 +49,4 @@ "keywords": [ | ||
"plugins", | ||
"dist", | ||
"examples" | ||
"dist" | ||
], | ||
"directories": { | ||
"bin": "./bin", | ||
"lib": "./lib", | ||
"example": "./examples" | ||
}, | ||
"scripts": { | ||
@@ -59,0 +53,0 @@ "test": "nyc --reporter=html --reporter=text mocha \"test/*/_index.js\"", |
@@ -623,4 +623,2 @@ /* global a2c */ | ||
exports.intersects = function(path1, path2) { | ||
if (path1.length < 3 || path2.length < 3) return false; // nothing to fill | ||
// Collect points of every subpath. | ||
@@ -627,0 +625,0 @@ var points1 = relative2absolute(path1).reduce(gatherPoints, []), |
@@ -187,2 +187,3 @@ **english** | [русский](https://github.com/svg/svgo/blob/master/README.ru.md) | ||
* as a web app – [SVGOMG](https://jakearchibald.github.io/svgomg/) | ||
* as a GitHub Action – [SVGO Action](https://github.com/marketplace/actions/svgo-action) | ||
* as a Nodejs module – [examples](https://github.com/svg/svgo/tree/master/examples) | ||
@@ -200,2 +201,5 @@ * as a Grunt task – [grunt-svgmin](https://github.com/sindresorhus/grunt-svgmin) | ||
* as a Rollup plugin - [rollup-plugin-svgo](https://github.com/porsager/rollup-plugin-svgo) | ||
* as a VS Code plugin - [vscode-svgo](https://github.com/1000ch/vscode-svgo) | ||
* as a Atom plugin - [atom-svgo](https://github.com/1000ch/atom-svgo) | ||
* as a Sublime plugin - [Sublime-svgo](https://github.com/1000ch/Sublime-svgo) | ||
* as a Figma plugin - [Advanced SVG Export](https://www.figma.com/c/plugin/782713260363070260/Advanced-SVG-Export) | ||
@@ -202,0 +206,0 @@ |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
220
3
0
1857555
73
54286