lib/compiler/blocks.js
function getBlocks(ast) {
  ast = Array.isArray(ast) ? ast : [ast];

  return ast.map((node) => {
    if (t.isReturnStatement(node)) {
      return getBlocks(node.argument);
    }
    if (t.isConditionalExpression(node)) {
      return node.alternate ? [
        ...getBlocks(node.consequent),
        ...getBlocks(node.alternate),
      ] : getBlocks(node.consequent);
    }
    if (t.isBinaryExpression(node)) {
      return handleBinaryExpression(node);
    }

    return null;
  }).filter(Boolean).reduce((prev, arr) => prev.concat(arr), []);
}
function getBlocks(ast) {
  ast = Array.isArray(ast) ? ast : [ast];

  return ast.map((node) => {
    if (t.isReturnStatement(node)) {
      return getBlocks(node.argument);
    }
    if (t.isConditionalExpression(node)) {
      return node.alternate ? [
        ...getBlocks(node.consequent),
        ...getBlocks(node.alternate),
      ] : getBlocks(node.consequent);
    }
    if (t.isBinaryExpression(node)) {
      return handleBinaryExpression(node);
    }

    return null;
  }).filter(Boolean).reduce((prev, arr) => prev.concat(arr), []);
}
function getBlocks ( ast ) { ast = Array . isArray ( ast ) ? ast : [ ast ] ; return ast . map ( ( node ) => { if ( t . isReturnStatement ( node ) ) { return getBlocks ( node . argument ) ; } if ( t . isConditionalExpression ( node ) ) { return node . alternate ? [ ... getBlocks ( node . consequent ) , ... getBlocks ( node . alternate ) , ] : getBlocks ( node . consequent ) ; } if ( t . isBinaryExpression ( node ) ) { return handleBinaryExpression ( node ) ; } return null ; } ) . filter ( Boolean ) . reduce ( ( prev , arr ) => prev . concat ( arr ) , [ ] ) ; }
Get block from ast array
@param {object[]} ast
@returns {object}
Get block from ast array