Pot.getFunctionCode

{String} Pot.getFunctionCode ({Function|String} func)

Pot.js と PotLite.js で利用可能。

引数 func の function 内部コードを文字列で取得します。

関数内の内部コード文字列を取得します。
引数 func に、対象の関数 もしくは 文字列を指定します。
取得した内部コードは、宣言時のものとは変化している可能性があります。
この差は、実行環境により違いがでるので注意してください。

Pot.globalize() が適応されている場合、Pot.getFunctionCode() が getFunctionCode() で実行できます。

取得した function コードが返ります。

debug(getFunctionCode(function() { return 'hoge'; }));
// e.g.
//   'function () {' +
//   '    return "hoge";' +
//   '}'
debug(getFunctionCode('function() { return 1; }'));
// e.g. 'function() { return 1; }'
debug(getFunctionCode(1));      // ''
debug(getFunctionCode(false));  // ''
debug(getFunctionCode(true));   // ''
debug(getFunctionCode(null));   // ''
debug(getFunctionCode(void 0)); // ''
debug(getFunctionCode({}));     // ''
debug(getFunctionCode(new Function('return 1')));
// e.g.
//   'function anonymous() {' +
//   '    return 1;' +
//   '}'