-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow to do a multiple optimizations with one init (close #25)
- Loading branch information
deepsweet
committed
Oct 26, 2012
1 parent
aa3fa83
commit 50a8c8a
Showing
6 changed files
with
91 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,59 @@ | ||
var CONFIG = require('./config'), | ||
SVG2JS = require('./svg2js'), | ||
PLUGINS = require('./plugins'), | ||
JS2SVG = require('./js2svg'); | ||
|
||
/** | ||
* SVGO is a Nodejs-based tool for optimizing SVG vector graphics files. | ||
* | ||
* @see http://deepsweet.github.com/svgo/ | ||
* | ||
* @module svgo | ||
* | ||
* @param {String} svgdata input data | ||
* @param {Object} [options] options | ||
* @return {String} output data deferred promise | ||
* | ||
* @author Kir Belevich <kir@soulshine.in> (https://github.com/deepsweet) | ||
* @copyright © 2012 Kir Belevich | ||
* @license MIT https://raw.github.com/deepsweet/svgo/master/LICENSE | ||
*/ | ||
module.exports = function(svgdata, options) { | ||
|
||
return CONFIG(options) | ||
.then(function(config) { | ||
var INHERIT = require('inherit'), | ||
CONFIG = require('./config'), | ||
SVG2JS = require('./svg2js'), | ||
PLUGINS = require('./plugins'), | ||
JS2SVG = require('./js2svg'); | ||
|
||
/** | ||
* @class SVGO. | ||
*/ | ||
module.exports = INHERIT(/** @lends SVGO.prototype */{ | ||
|
||
/** | ||
* @param {Object} [config] config to extend | ||
* | ||
* @constructs | ||
* | ||
* @private | ||
*/ | ||
__constructor: function(config) { | ||
|
||
this.config = CONFIG(config); | ||
|
||
}, | ||
|
||
/** | ||
* Main optimize function. | ||
* | ||
* @param {String} svgdata input data | ||
* @return {String} output data deferred promise | ||
*/ | ||
optimize: function(svgdata) { | ||
|
||
return this.config | ||
.then(function(config) { | ||
|
||
return SVG2JS(svgdata, config.svg2js) | ||
.then(function(jsdata) { | ||
|
||
return SVG2JS(svgdata, config.svg2js) | ||
.then(function(jsdata) { | ||
return JS2SVG(PLUGINS(jsdata, config.plugins), config.js2svg); | ||
|
||
return JS2SVG(PLUGINS(jsdata, config.plugins), config.js2svg); | ||
}); | ||
|
||
}); | ||
}); | ||
|
||
}); | ||
} | ||
|
||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters