lib/misc/utils.js
function arrowFnToNormalFn(string) {
  var match = string.match(/^([\s\S]+?)=\>(\s*{)?([\s\S]*?)(}\s*)?$/);

  if (!match) {
    return string;
  }

  var args = match[1];
  var body = match[3];

  var needsReturn = !(match[2] && match[4]);

  args = args.replace(/^(\s*\(\s*)([\s\S]*?)(\s*\)\s*)$/, '$2');

  if (needsReturn) {
    body = 'return ' + body;
  }

  return 'function(' + args + ') {' + body + '}';
}
function arrowFnToNormalFn(string) {
  var match = string.match(/^([\s\S]+?)=\>(\s*{)?([\s\S]*?)(}\s*)?$/);

  if (!match) {
    return string;
  }

  var args = match[1];
  var body = match[3];

  var needsReturn = !(match[2] && match[4]);

  args = args.replace(/^(\s*\(\s*)([\s\S]*?)(\s*\)\s*)$/, '$2');

  if (needsReturn) {
    body = 'return ' + body;
  }

  return 'function(' + args + ') {' + body + '}';
}
function arrowFnToNormalFn ( string ) { var match = string . match ( / ^([\s\S]+?)=\>(\s*{)?([\s\S]*?)(}\s*)?$ / ) ; if ( ! match ) { return string ; } var args = match [ 1 ] ; var body = match [ 3 ] ; var needsReturn = ! ( match [ 2 ] && match [ 4 ] ) ; args = args . replace ( / ^(\s*\(\s*)([\s\S]*?)(\s*\)\s*)$ / , '$2' ) ; if ( needsReturn ) { body = 'return ' + body ; } return 'function(' + args + ') {' + body + '}' ; }
Migrate to separate npm-package with full tests
Migrate to separate npm - package with full tests