Skip to content

Commit

Permalink
perf: ⚡️ store all units in a string
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Jul 14, 2018
1 parent 405a30c commit 7142d86
Showing 1 changed file with 3 additions and 19 deletions.
22 changes: 3 additions & 19 deletions addon/units.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,14 @@
'use strict';

var units = {};
var list = [
'px',
'cm',
'mm',
'in',
'pt',
'pc',
'em',
'ex',
'ch',
'rem',
'vw',
'vh',
'deg',
'vmin',
'vmax',
];
var unitList = 'px,cm,mm,in,pt,pc,em,ex,ch,rem,vw,vh,deg,vmin,vmax'.split(',');

function f (unit, val) {
return val + unit;
}

for (var i = 0; i < list.length; i++) {
var unit = list[i];
for (var i = 0; i < unitList.length; i++) {
var unit = unitList[i];

units[unit] = f.bind(null, unit);
}
Expand Down

0 comments on commit 7142d86

Please sign in to comment.