Comparing version 1.1.1 to 1.2.0
{ | ||
"name": "css-font", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"description": "Parse or stringify CSS font property.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
18
parse.js
@@ -12,5 +12,14 @@ 'use strict' | ||
module.exports = function parseFont (value) { | ||
module.exports = parseFont | ||
var cache = parseFont.cache = {} | ||
function parseFont (value) { | ||
if (typeof value !== 'string') throw new Error('Font argument must be a string.') | ||
if (cache[value]) return cache[value] | ||
if (value === '') { | ||
@@ -21,3 +30,3 @@ throw new Error('Cannot parse an empty string.') | ||
if (systemFontKeywords.indexOf(value) !== -1) { | ||
return { system: value } | ||
return cache[value] = {system: value} | ||
} | ||
@@ -43,3 +52,4 @@ | ||
}) | ||
return font | ||
return cache[value] = font | ||
} | ||
@@ -84,3 +94,3 @@ | ||
return font | ||
return cache[value] = font | ||
} | ||
@@ -87,0 +97,0 @@ |
@@ -38,3 +38,3 @@ 'use strict' | ||
stretch: 'stretch font-stretch fontStretch fontstretch width', | ||
size: 'size s font-size fontSize fontsize height', | ||
size: 'size s font-size fontSize fontsize height em emSize', | ||
lineHeight: 'lh line-height lineHeight lineheight leading', | ||
@@ -41,0 +41,0 @@ family: 'font family fontFamily font-family fontfamily type typeface face', |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11421
177