You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
556 B

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