Skip to content

Commit

Permalink
Remove unnecessary dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeti-or committed Mar 22, 2017
1 parent 40a9353 commit 4495a34
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 28 deletions.
16 changes: 7 additions & 9 deletions lib/svgo/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
var FS = require('fs');
var yaml = require('js-yaml');

var EXTEND = require('whet.extend');

/**
* Read and/or extend/replace default config file,
* prepare and optimize plugins array.
Expand All @@ -28,7 +26,7 @@ module.exports = function(config) {
defaults.plugins = preparePluginsArray(defaults.plugins);
}
} else {
defaults = EXTEND({}, yaml.safeLoad(FS.readFileSync(__dirname + '/../../.svgo.yml', 'utf8')));
defaults = Object.assign({}, yaml.safeLoad(FS.readFileSync(__dirname + '/../../.svgo.yml', 'utf8')));
defaults.plugins = preparePluginsArray(defaults.plugins);
defaults = extendConfig(defaults, config);
}
Expand All @@ -37,7 +35,7 @@ module.exports = function(config) {
defaults.plugins.forEach(function(plugin) {
if (plugin.params && ('floatPrecision' in plugin.params)) {
// Don't touch default plugin params
plugin.params = EXTEND({}, plugin.params, { floatPrecision: config.floatPrecision });
plugin.params = Object.assign({}, plugin.params, { floatPrecision: config.floatPrecision });
}
});
}
Expand Down Expand Up @@ -74,11 +72,11 @@ function preparePluginsArray(plugins) {

} else {

plugin = EXTEND({}, require('../../plugins/' + key));
plugin = Object.assign({}, require('../../plugins/' + key));

// name: {}
if (typeof item[key] === 'object') {
plugin.params = EXTEND({}, plugin.params || {}, item[key]);
plugin.params = Object.assign({}, plugin.params || {}, item[key]);
plugin.active = true;

// name: false
Expand All @@ -96,7 +94,7 @@ function preparePluginsArray(plugins) {
// name
} else {

plugin = EXTEND({}, require('../../plugins/' + item));
plugin = Object.assign({}, require('../../plugins/' + item));
plugin.name = item;

}
Expand Down Expand Up @@ -138,7 +136,7 @@ function extendConfig(defaults, config) {
if (plugin.name === key) {
// name: {}
if (typeof item[key] === 'object') {
plugin.params = EXTEND({}, plugin.params || {}, item[key]);
plugin.params = Object.assign({}, plugin.params || {}, item[key]);
plugin.active = true;

// name: false
Expand Down Expand Up @@ -184,7 +182,7 @@ function extendConfig(defaults, config) {
*/
function setupCustomPlugin(name, plugin) {
plugin.active = true;
plugin.params = EXTEND({}, plugin.params || {});
plugin.params = Object.assign({}, plugin.params || {});
plugin.name = name;

return plugin;
Expand Down
3 changes: 1 addition & 2 deletions lib/svgo/js2svg.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

var EOL = require('os').EOL,
EXTEND = require('whet.extend'),
textElem = require('../../plugins/_collections.js').elemsGroups.textContent.concat('title');

var defaults = {
Expand Down Expand Up @@ -56,7 +55,7 @@ module.exports = function(data, config) {
function JS2SVG(config) {

if (config) {
this.config = EXTEND(true, {}, defaults, config);
this.config = Object.assign({}, defaults, config);
} else {
this.config = defaults;
}
Expand Down
5 changes: 1 addition & 4 deletions lib/svgo/jsAPI.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
'use strict';

var EXTEND = require('whet.extend');

var JSAPI = module.exports = function(data, parentNode) {
EXTEND(this, data);
Object.assign(this, data);
if (parentNode) {
Object.defineProperty(this, 'parentNode', {
writable: true,
Expand All @@ -28,7 +26,6 @@ JSAPI.prototype.clone = function() {
});

// Deep-clone node data
// This is still faster than using EXTEND(true…)
nodeData = JSON.parse(JSON.stringify(nodeData));

// parentNode gets set to a proper object by the parent clone,
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
"coa": "~1.0.1",
"js-yaml": "~3.7.0",
"colors": "~1.1.2",
"whet.extend": "~0.9.9",
"mkdirp": "~0.5.1",
"csso": "~2.3.1"
},
Expand Down
4 changes: 1 addition & 3 deletions plugins/_path.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ var relative2absolute = exports.relative2absolute = function(data) {
subpathPoint = [0, 0],
i;

data = data.map(function(item) {
return data.map(function(item) {

var instruction = item.instruction,
itemData = item.data && item.data.slice();
Expand Down Expand Up @@ -160,8 +160,6 @@ var relative2absolute = exports.relative2absolute = function(data) {
};

});

return data;
};

/**
Expand Down
5 changes: 2 additions & 3 deletions plugins/convertStyleToAttrs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ exports.active = true;

exports.description = 'converts style to attributes';

var EXTEND = require('whet.extend'),
stylingProps = require('./_collections').attrsGroups.presentation,
var stylingProps = require('./_collections').attrsGroups.presentation,
rEscape = '\\\\(?:[0-9a-f]{1,6}\\s?|\\r\\n|.)', // Like \" or \2051. Code points consume one space.
rAttr = '\\s*(' + g('[^:;\\\\]', rEscape) + '*?)\\s*', // attribute name like ‘fill’
rSingleQuotes = "'(?:[^'\\n\\r\\\\]|" + rEscape + ")*?(?:'|$)", // string in single quotes: 'smth'
Expand Down Expand Up @@ -96,7 +95,7 @@ exports.fn = function(item) {
return true;
});

EXTEND(item.attrs, attrs);
Object.assign(item.attrs, attrs);

if (styles.length) {
item.attr('style').value = styles
Expand Down
3 changes: 1 addition & 2 deletions plugins/convertTransform.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ exports.params = {
};

var cleanupOutData = require('../lib/svgo/tools').cleanupOutData,
EXTEND = require('whet.extend'),
transform2js = require('./_transforms.js').transform2js,
transformsMultiply = require('./_transforms.js').transformsMultiply,
matrixToTransform = require('./_transforms.js').matrixToTransform,
Expand Down Expand Up @@ -116,7 +115,7 @@ function definePrecision(data, params) {
significantDigits = params.transformPrecision;

// Clone params so it don't affect other elements transformations.
params = EXTEND({}, params);
params = Object.assign({}, params);

// Limit transform precision with matrix one. Calculating with larger precision doesn't add any value.
if (matrixData.length) {
Expand Down
7 changes: 3 additions & 4 deletions plugins/transformsWithOnePath.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,12 @@ exports.params = {
};

var _path = require('./_path.js'),
relative2absolute = _path.relative2absolute,
relative2absolute = _path.eelative2absolute,
computeCubicBoundingBox = _path.computeCubicBoundingBox,
computeQuadraticBoundingBox = _path.computeQuadraticBoundingBox,
applyTransforms = _path.applyTransforms,
js2path = _path.js2path,
path2js = _path.path2js,
EXTEND = require('whet.extend');
path2js = _path.path2js;

exports.fn = function(data, params) {

Expand All @@ -56,7 +55,7 @@ exports.fn = function(data, params) {
var svgElem = item,
pathElem = svgElem.content[0],
// get absoluted Path data
path = relative2absolute(EXTEND(true, [], path2js(pathElem))),
path = relative2absolute(path2js(pathElem)),
xs = [],
ys = [],
cubicСontrolPoint = [0, 0],
Expand Down

0 comments on commit 4495a34

Please sign in to comment.