function merge (node, data) { for (const key in data) { const val = data[key] node[camelCase(key)] = isObject(val) ? merge({}, val) : val } return node }
function resolveElementType(type) { // Try to match '<node-module-name>.<component-name>' const [moduleName, componentName] = type.split('.'); if (moduleName && componentName) { // Add a module import based on the type. let className; const imports = {}; if (componentName === 'default') { // Import is 'import <import-name> from <node-module-name>' const importName = camelCase(moduleName); imports[moduleName] = [`default:${importName}`]; className = importName; } else { // Import is 'import { <component-name> } from '<node-module-name>' const [importName] = (componentName.match(/^([^\.]+)\.?(.+)?/) || []).slice(1); imports[moduleName] = [importName]; className = componentName; } return { className, imports }; } else if (moduleName) { // Type is a literal React component name (e.g. 'div') return { className: `'${moduleName}'`, imports: {} }; } else { throw new Error(`Illegal element type ${type}`); } }
const key = camelCase(name) const val = values[i]