Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

imagemin-svgo

Package Overview
Dependencies
Maintainers
2
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

imagemin-svgo - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

73

index.js

@@ -10,3 +10,41 @@ 'use strict';

*
* @param {Object} file
* @param {String} enc
* @param {Object} opts
* @param {Function} cb
* @api private
*/
function plugin(file, enc, opts, cb) {
if (file.isNull()) {
cb(null, file);
return;
}
if (file.isStream()) {
cb(new Error('Streaming is not supported'));
return;
}
if (!isSvg(file.contents)) {
cb(null, file);
return;
}
var svgo = new SVGO({ plugins: opts.plugins || [] });
try {
svgo.optimize(file.contents.toString('utf8'), function (res) {
file.contents = new Buffer(res.data);
cb(null, file);
});
} catch (err) {
cb(err);
}
}
/**
* Module exports
*
* @param {Object} opts
* @api public

@@ -19,28 +57,19 @@ */

return through.obj(function (file, enc, cb) {
if (file.isNull()) {
cb(null, file);
return;
}
plugin(file, enc, opts, cb);
});
};
if (file.isStream()) {
cb(new Error('Streaming is not supported'));
return;
}
/**
* Module exports constructor
*
* @param {Object} opts
* @api public
*/
if (!isSvg(file.contents)) {
cb(null, file);
return;
}
module.exports.ctor = function (opts) {
opts = opts || {};
var svgo = new SVGO({ plugins: opts.plugins || [] });
try {
svgo.optimize(file.contents.toString('utf8'), function (res) {
file.contents = new Buffer(res.data);
cb(null, file);
});
} catch (err) {
cb(err);
}
return through.ctor({ objectMode: true }, function (file, enc, cb) {
plugin(file, enc, opts, cb);
});
};
{
"name": "imagemin-svgo",
"version": "2.0.0",
"version": "2.1.0",
"description": "svgo imagemin plugin",

@@ -23,2 +23,3 @@ "license": "MIT",

"compress",
"gulpplugin",
"image",

@@ -29,3 +30,4 @@ "imageminplugin",

"optimize",
"svg"
"svg",
"svgo"
],

@@ -39,4 +41,4 @@ "dependencies": {

"ava": "0.0.4",
"vinyl": "^0.4.3"
"vinyl-file": "^1.1.0"
}
}
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc