_toSource.js 484 B

1234567891011121314151617181920212223
  1. /** Used to resolve the decompiled source of functions. */
  2. var funcToString = Function.prototype.toString;
  3. /**
  4. * Converts `func` to its source code.
  5. *
  6. * @private
  7. * @param {Function} func The function to process.
  8. * @returns {string} Returns the source code.
  9. */
  10. function toSource(func) {
  11. if (func != null) {
  12. try {
  13. return funcToString.call(func);
  14. } catch (e) {}
  15. try {
  16. return (func + '');
  17. } catch (e) {}
  18. }
  19. return '';
  20. }
  21. module.exports = toSource;