I hereby claim:
- I am jtfell on github.
- I am jtfell (https://keybase.io/jtfell) on keybase.
- I have a public key ASDgcNU_Bf-9CwPZNlSSVwZ8jc5tJTOfuU7TPut4LgD05Ao
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
{ | |
"numFailedTests": 0, | |
"numPassedTests": 3, | |
"numPendingTests": 0, | |
"startTime": 1514867328411, | |
"success": false, | |
"sovereignty": "eu", | |
"environment": "master", | |
"testExecutions": [ | |
{ |
var fs = require('fs'); | |
var analyse = require('../src/index.js'); | |
var css = fs.readFileSync('./test/basic.css', 'utf8'); | |
analyse(css); | |
// Prints: | |
// { ratio: 1.4999140493583407, fit: 0.9999999752384222 } |
function calculateRatio(xs) { | |
var uniqueSizes = xs.sort().filter(onlyUnique); | |
return exponentialRegression(uniqueSizes); | |
} | |
function onlyUnique(value, index, self) { | |
return self.indexOf(value) === index; | |
} |
function findFontSizeDecl(root) { | |
var vals = []; | |
// Iterate over font-size declarations | |
root.walkDecls(/font-size/, function(decl) { | |
vals.push(convertToEm(decl.value)); | |
}); | |
return vals; | |
}; |
var postcss = require('postcss'); | |
module.exports = function(css) { | |
var root = postcss.parse(css); | |
// 1. Parse the AST and collect all font-size declarations | |
var properties = findFontSizeDecl(root); | |
// 2. Calculate the ratio used and the quality of the fit | |
var results = calculateRatio(properties); |