UNPKG

554 BJavaScriptView Raw
1/** Used for built-in method references. */
2var funcProto = Function.prototype;
3
4/** Used to resolve the decompiled source of functions. */
5var funcToString = funcProto.toString;
6
7/**
8 * Converts `func` to its source code.
9 *
10 * @private
11 * @param {Function} func The function to convert.
12 * @returns {string} Returns the source code.
13 */
14function toSource(func) {
15 if (func != null) {
16 try {
17 return funcToString.call(func);
18 } catch (e) {}
19 try {
20 return (func + '');
21 } catch (e) {}
22 }
23 return '';
24}
25
26export default toSource;