PHP 8.2.30
Preview: object-to-string.js Size: 1.26 KB
/proc/thread-self/root/home/byroehnu/.trash/node_modules11/@emotion/babel-plugin/src/utils/object-to-string.js

import { serializeStyles } from '@emotion/serialize'

// to anyone looking at this, this isn't intended to simplify every single case
// it's meant to simplify the most common cases so i don't want to make it especially complex
// also, this will be unnecessary when prepack is ready
export function simplifyObject(node, t /*: Object */) {
  let finalString = ''
  for (let i = 0; i < node.properties.length; i++) {
    let property = node.properties[i]

    if (
      !t.isObjectProperty(property) ||
      property.computed ||
      (!t.isIdentifier(property.key) && !t.isStringLiteral(property.key)) ||
      (!t.isStringLiteral(property.value) &&
        !t.isNumericLiteral(property.value) &&
        !t.isObjectExpression(property.value))
    ) {
      return node
    }

    let key = property.key.name || property.key.value
    if (key === 'styles') {
      return node
    }
    if (t.isObjectExpression(property.value)) {
      let simplifiedChild = simplifyObject(property.value, t)
      if (!t.isStringLiteral(simplifiedChild)) {
        return node
      }
      finalString += `${key}{${simplifiedChild.value}}`
      continue
    }
    let value = property.value.value

    finalString += serializeStyles([{ [key]: value }]).styles
  }
  return t.stringLiteral(finalString)
}

Directory Contents

Dirs: 0 × Files: 13

Name Size Perms Modified Actions
750 B lrw-r--r-- 2026-02-28 00:26:46
Edit Download
373 B lrw-r--r-- 2026-02-28 00:27:12
Edit Download
2.79 KB lrw-r--r-- 2026-02-28 00:28:00
Edit Download
1.49 KB lrw-r--r-- 2026-02-28 00:28:06
Edit Download
537 B lrw-r--r-- 2026-02-28 00:28:12
Edit Download
4.62 KB lrw-r--r-- 2026-02-28 00:28:18
Edit Download
3.91 KB lrw-r--r-- 2026-02-28 00:28:22
Edit Download
1.26 KB lrw-r--r-- 2026-02-28 00:28:24
Edit Download
1.07 KB lrw-r--r-- 2026-02-28 00:28:26
Edit Download
1.90 KB lrw-r--r-- 2026-02-28 00:28:28
Edit Download
4.21 KB lrw-r--r-- 2026-02-28 00:28:30
Edit Download
1.65 KB lrw-r--r-- 2026-02-28 00:28:32
Edit Download
2.28 KB lrw-r--r-- 2026-02-28 00:28:32
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).