-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
34 lines (27 loc) · 893 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"use strict";
var jsvg = require('nano-svg2js');
module.exports = {
'parse': function sync(log, data) {
if (data.encoding !== 'utf8')
throw TypeError('data.encoding should be equal "utf8"');
return jsvg.parseSVG(data.content).then(function (jsvg) {
data.content = jsvg;
data.encoding = 'json';
});
},
'optimize-ids': function sync(log, data) {
if (data.encoding !== 'json')
throw TypeError('data.encoding should be equal "json"');
data.content = jsvg.optimizeIds(data.content, data.opts['svg-ids-prefix'] || '$');
},
'optimize': function sync(log, data) {
if (data.encoding !== 'json')
throw TypeError('data.encoding should be equal "json"');
data.content = jsvg.optimizeJSVG(data.content);
},
'pack': function sync(log, data) {
if (data.encoding !== 'json')
throw TypeError('data.encoding should be equal "json"');
data.content = jsvg.packJSVG(data.content);
}
};