Skip to content

Instantly share code, notes, and snippets.

@natew
Created October 17, 2015 17:40
Show Gist options
  • Save natew/a23163d44b3971a63e6a to your computer and use it in GitHub Desktop.
Save natew/a23163d44b3971a63e6a to your computer and use it in GitHub Desktop.
if (t.isArrayExpression(node.right)) {
let staticProps = []
node.right.elements = node.right.elements.map(el => {
if (!t.isObjectExpression(el)) return el
let { statics, dynamics } = extractStatics(el)
if (statics.length) staticProps.push(statics)
if (dynamics.length) return t.objectExpression(dynamics)
else return null
}).filter(x => x !== null)
return [
staticStatement(node, t.objectExpression(staticProps)),
dynamicStatement(node, node.right)
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment