MCPcopy Index your code
hub / github.com/codeceptjs/CodeceptJS / convertFontWeightToNumber

Function convertFontWeightToNumber

lib/utils.js:289–312  ·  view source on GitHub ↗
(name)

Source from the content-addressed store, hash-verified

287}
288
289function convertFontWeightToNumber(name) {
290 const fontWeightPatterns = [
291 { num: 100, pattern: /^Thin$/i },
292 { num: 200, pattern: /^(Extra|Ultra)-?light$/i },
293 { num: 300, pattern: /^Light$/i },
294 { num: 400, pattern: /^(Normal|Regular|Roman|Book)$/i },
295 { num: 500, pattern: /^Medium$/i },
296 { num: 600, pattern: /^(Semi|Demi)-?bold$/i },
297 { num: 700, pattern: /^Bold$/i },
298 { num: 800, pattern: /^(Extra|Ultra)-?bold$/i },
299 { num: 900, pattern: /^(Black|Heavy)$/i },
300 ]
301
302 if (/^[1-9]00$/.test(name)) {
303 return Number(name)
304 }
305
306 const matches = fontWeightPatterns.filter(fontWeight => fontWeight.pattern.test(name))
307
308 if (matches.length) {
309 return String(matches[0].num)
310 }
311 return name
312}
313
314function isFontWeightProperty(prop) {
315 return prop === 'fontWeight'

Callers 1

Calls 1

filterMethod · 0.80

Tested by

no test coverage detected