CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes48downloads
objectifier.js94 linesDownload Raw Back to postcss-js
1let camelcase = require('camelcase-css')2 3let UNITLESS = {4  boxFlex: true,5  boxFlexGroup: true,6  columnCount: true,7  flex: true,8  flexGrow: true,9  flexPositive: true,10  flexShrink: true,11  flexNegative: true,12  fontWeight: true,13  lineClamp: true,14  lineHeight: true,15  opacity: true,16  order: true,17  orphans: true,18  tabSize: true,19  widows: true,20  zIndex: true,21  zoom: true,22  fillOpacity: true,23  strokeDashoffset: true,24  strokeOpacity: true,25  strokeWidth: true26}27 28function atRule(node) {29  if (typeof node.nodes === 'undefined') {30    return true31  } else {32    return process(node)33  }34}35 36function process(node, options = {}) {37  let name38  let result = {}39  let { stringifyImportant } = options;40 41  node.each(child => {42    if (child.type === 'atrule') {43      name = '@' + child.name44      if (child.params) name += ' ' + child.params45      if (typeof result[name] === 'undefined') {46        result[name] = atRule(child)47      } else if (Array.isArray(result[name])) {48        result[name].push(atRule(child))49      } else {50        result[name] = [result[name], atRule(child)]51      }52    } else if (child.type === 'rule') {53      let body = process(child)54      if (result[child.selector]) {55        for (let i in body) {56          let object = result[child.selector];57          if (stringifyImportant && object[i] && object[i].endsWith('!important')) {58            if (body[i].endsWith('!important')) {59              object[i] = body[i]60            }61          } else {62            object[i] = body[i]63          }64        }65      } else {66        result[child.selector] = body67      }68    } else if (child.type === 'decl') {69      if (child.prop[0] === '-' && child.prop[1] === '-') {70        name = child.prop71      } else if (child.parent && child.parent.selector === ':export') {72        name = child.prop73      } else {74        name = camelcase(child.prop)75      }76      let value = child.value77      if (!isNaN(child.value) && UNITLESS[name]) {78        value = parseFloat(child.value)79      }80      if (child.important) value += ' !important'81      if (typeof result[name] === 'undefined') {82        result[name] = value83      } else if (Array.isArray(result[name])) {84        result[name].push(value)85      } else {86        result[name] = [result[name], value]87      }88    }89  })90  return result91}92 93module.exports = process94 
basant307/AI_Governance_Project · CoolFace