src/index.js
function unwrapReturns(ast, src, result) {
  const charArray = src.split('');

  const state = {
    hasReturn: false,
    source(node) {
      return src.slice(node.start, node.end);
    },
    replace(node, str) {
      charArray.fill('', node.start, node.end);
      charArray[node.start] = str;
    }
  };

  walk(ast, unwrapReturnsVisitors, state);

  return {
    before: state.hasReturn ? `var ${result} = ` : '',
    body: charArray.join(''),
    after: state.hasReturn ? `;if (${result}) return ${result}.value` : ''
  };
}
function unwrapReturns(ast, src, result) {
  const charArray = src.split('');

  const state = {
    hasReturn: false,
    source(node) {
      return src.slice(node.start, node.end);
    },
    replace(node, str) {
      charArray.fill('', node.start, node.end);
      charArray[node.start] = str;
    }
  };

  walk(ast, unwrapReturnsVisitors, state);

  return {
    before: state.hasReturn ? `var ${result} = ` : '',
    body: charArray.join(''),
    after: state.hasReturn ? `;if (${result}) return ${result}.value` : ''
  };
}
function unwrapReturns ( ast , src , result ) { const charArray = src . split ( '' ) ; const state = { hasReturn : false , source ( node ) { return src . slice ( node . start , node . end ) ; } , replace ( node , str ) { charArray . fill ( '' , node . start , node . end ) ; charArray [ node . start ] = str ; } } ; walk ( ast , unwrapReturnsVisitors , state ) ; return { before : state . hasReturn ? ` ${ result } ` : '' , body : charArray . join ( '' ) , after : state . hasReturn ? ` ${ result } ${ result } ` : '' } ; }
Take a self calling function, and unwrap it such that return inside the function
results in return outside the function

@param {String} src    Some JavaScript code representing a self-calling function
@param {String} result A temporary variable to store the result in
Take a self calling function and unwrap it such that return inside the function results in return outside the function