Raw File
getFunctionName.js
'use strict';

const functionNameRE = /^function\s*([^\s(]+)/;

module.exports = function(fn) {
  return (
    fn.name ||
    (fn.toString().trim().match(functionNameRE) || [])[1]
  );
};
back to top