I have some old code and I need to refactor/rewrite arguments.callee.caller.caller and arguments.callee.caller in two funcs to be able to 'use strict'. Can be max up to ECMAScript 2019, thanks!
const utils = {
/**
* @return {string}
*/
caller: function (string, callerName) {
const caller = /^function\s+([^(]+)/.exec(/** @type{string} */ arguments.callee.caller.caller.toString());
return caller ? caller[1] : '';
},
/**
* @return {string}
*/
function_name: function () {
const caller = /^function\s+([^(]+)/.exec(/** @type{string} */ arguments.callee.caller.toString());
return caller ? caller[1] : '';
}
};