function buildConcatCallExpressions(items) {
    let avail = true;
    return items.reduce(function(left, right) {
      let canBeInserted = t.isLiteral(right);

      if (!canBeInserted && avail) {
        canBeInserted = true;
        avail = false;
      }
      if (canBeInserted && t.isCallExpression(left)) {
        left.arguments.push(right);
        return left;
      }
      return t.callExpression(
        t.memberExpression(left, t.identifier("concat")),
        [right],
      );
    });
  }
function buildConcatCallExpressions(items) {
    let avail = true;
    return items.reduce(function(left, right) {
      let canBeInserted = t.isLiteral(right);

      if (!canBeInserted && avail) {
        canBeInserted = true;
        avail = false;
      }
      if (canBeInserted && t.isCallExpression(left)) {
        left.arguments.push(right);
        return left;
      }
      return t.callExpression(
        t.memberExpression(left, t.identifier("concat")),
        [right],
      );
    });
  }
function buildConcatCallExpressions ( items ) { let avail = true ; return items . reduce ( function ( left , right ) { let canBeInserted = t . isLiteral ( right ) ; if ( ! canBeInserted && avail ) { canBeInserted = true ; avail = false ; } if ( canBeInserted && t . isCallExpression ( left ) ) { left . arguments . push ( right ) ; return left ; } return t . callExpression ( t . memberExpression ( left , t . identifier ( "concat" ) ) , [ right ] , ) ; } ) ; }
This function groups the objects into multiple calls to `.concat()` in
order to preserve execution order of the primitive conversion, e.g.

"".concat(obj.foo, "foo", obj2.foo, "foo2")

would evaluate both member expressions _first_ then, `concat` will
convert each one to a primitive, whereas

"".concat(obj.foo, "foo").concat(obj2.foo, "foo2")

would evaluate the member, then convert it to a primitive, then evaluate
the second member and convert that one, which reflects the spec behavior
of template literals.
This function groups the objects into multiple calls to . concat () in order to preserve execution order of the primitive conversion e . g .
Build concat call expressions