parse.js 323 B

123456789101112131415161718
  1. /**
  2. * Source lines numeration:
  3. *
  4. * 0 function() {
  5. * 1 // source with comments
  6. * 2 }
  7. *
  8. */
  9. var parse = require('../index')
  10. module.exports = function (func, opts) {
  11. var str = func.toString()
  12. str = str
  13. .slice(str.indexOf('{') + 1, str.lastIndexOf('}'))
  14. .replace(/\r\n/g, '\n')
  15. return parse(str, opts)
  16. }