mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-31 07:17:50 +00:00
24 lines
548 B
JavaScript
24 lines
548 B
JavaScript
define(['./isFunction', './toString'], function(isFunction, toString) {
|
|
|
|
/** Used to resolve the decompiled source of functions. */
|
|
var funcToString = Function.prototype.toString;
|
|
|
|
/**
|
|
* Converts `func` to its source code.
|
|
*
|
|
* @private
|
|
* @param {Function} func The function to process.
|
|
* @returns {string} Returns the source code.
|
|
*/
|
|
function toSource(func) {
|
|
if (isFunction(func)) {
|
|
try {
|
|
return funcToString.call(func);
|
|
} catch (e) {}
|
|
}
|
|
return toString(func);
|
|
}
|
|
|
|
return toSource;
|
|
});
|