index.js
function astValue(node) {

  switch (node.type) {

  case 'ExpressionStatement':
    return astValue(node.expression);

  case 'ObjectExpression':
    return node.properties.reduce(
      (obj, prop) => Object.assign(obj, {[prop.key.value]: astValue(prop.value)}),
      {}
    );

  case 'ArrayExpression':
    return node.elements.map(element => astValue(element));

  case 'Literal':
    return node.value;

  default:
    throw new Error(`Unexpected ast node type: ${node.type}`);

  }
}
function astValue(node) {

  switch (node.type) {

  case 'ExpressionStatement':
    return astValue(node.expression);

  case 'ObjectExpression':
    return node.properties.reduce(
      (obj, prop) => Object.assign(obj, {[prop.key.value]: astValue(prop.value)}),
      {}
    );

  case 'ArrayExpression':
    return node.elements.map(element => astValue(element));

  case 'Literal':
    return node.value;

  default:
    throw new Error(`Unexpected ast node type: ${node.type}`);

  }
}
function astValue ( node ) { switch ( node . type ) { case 'ExpressionStatement' : return astValue ( node . expression ) ; case 'ObjectExpression' : return node . properties . reduce ( ( obj , prop ) => Object . assign ( obj , { [ prop . key . value ] : astValue ( prop . value ) } ) , { } ) ; case 'ArrayExpression' : return node . elements . map ( element => astValue ( element ) ) ; case 'Literal' : return node . value ; default : throw new Error ( ` ${ node . type } ` ) ; } }
Evaluate AST node to a value.

@param  {object} node Node to evaluate
@return {any}
Evaluate AST node to a value .