-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
parsers.js
88 lines (82 loc) · 2.26 KB
/
parsers.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/* Results on node 6.3.0, Fedora 23, Intel Core i7-6500U, 8 GB RAM and SSD:
Mensch: 24 ms (1.5 times faster)
CSSOM: 25 ms (1.4 times faster)
PostCSS: 37 ms
Rework: 47 ms (1.3 times slower)
Stylecow: 74 ms (2.0 times slower)
Gonzales: 113 ms (3.1 times slower)
Gonzales PE: 138 ms (3.8 times slower)
*/
var path = require('path');
var fs = require('fs');
var example = path.join(__dirname, 'cache', 'bootstrap.css');
var css = fs.readFileSync(example).toString();
var CSSOM = require('cssom');
var rework = require('rework');
var mensch = require('mensch');
var postcss = require('postcss');
var stylecow = require('stylecow-core');
var gonzales = require('gonzales');
var gonzalesPe = require('gonzales-pe');
module.exports = {
name: 'Bootstrap',
maxTime: 15,
tests: [
{
name: 'Rework',
fn: function () {
rework(css).toString();
}
},
{
name: 'PostCSS',
defer: true,
fn: function (done) {
postcss.parse(css, { from: example }).toResult();
done.resolve();
}
},
{
name: 'CSSOM',
fn: function () {
CSSOM.parse(css).toString();
}
},
{
name: 'Mensch',
fn: function () {
mensch.stringify( mensch.parse(css) );
}
},
{
name: 'Gonzales',
fn: function () {
gonzales.csspToSrc( gonzales.srcToCSSP(css) );
}
},
{
name: 'Gonzales PE',
fn: function () {
gonzalesPe.parse(css).toString();
}
},
{
name: 'Stylecow',
fn: function () {
stylecow.parse(css).toString();
}
}
]
};
var devPath = path.join(__dirname, '../postcss/build/lib/postcss.js');
if ( fs.existsSync(devPath) ) {
var devPostcss = require(devPath);
module.exports.tests.splice(1, 0, {
name: 'PostCSS dev',
defer: true,
fn: function (done) {
devPostcss.parse(css, { from: example }).toResult();
done.resolve();
}
});
}